本文整理汇总了C#中TreeView类的典型用法代码示例。如果您正苦于以下问题:C# TreeView类的具体用法?C# TreeView怎么用?C# TreeView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeView类属于命名空间,在下文中一共展示了TreeView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public void Run(string[] args)
{
Application.Init ();
PopulateStore ();
store.SetSortColumnId(2, SortType.Ascending);
Window win = new Window ("Gtk Widget Attributes");
win.DeleteEvent += new DeleteEventHandler (DeleteCB);
win.SetDefaultSize (640,480);
ScrolledWindow sw = new ScrolledWindow ();
win.Add (sw);
TreeView tv = new TreeView (store);
tv.HeadersVisible = true;
tv.AppendColumn ("Name", new CellRendererText (), "markup", 0);
tv.AppendColumn ("Type", new CellRendererText (), "text", 1);
foreach(TreeViewColumn col in tv.Columns)
col.Resizable = true;
tv.SearchColumn = 2;
sw.Add (tv);
dialog.Destroy ();
dialog = null;
win.ShowAll ();
Application.Run ();
}
示例2: MainForm
public MainForm ()
{
//
// _tree
//
_tree = new TreeView ();
_tree.Dock = DockStyle.Top;
_tree.Height = 100;
Controls.Add (_tree);
//
// _refreshButton
//
_refreshButton = new Button ();
_refreshButton.Location = new Point (8, 110);
_refreshButton.Text = "Refresh";
_refreshButton.Click += new EventHandler (RefreshButton_Click);
Controls.Add (_refreshButton);
//
// _visibleText
//
_visibleText = new TextBox ();
_visibleText.Dock = DockStyle.Bottom;
_visibleText.Height = 200;
_visibleText.Multiline = true;
_visibleText.ScrollBars = ScrollBars.Vertical;
Controls.Add (_visibleText);
//
// MainForm
//
ClientSize = new Size (400, 350);
Location = new Point (250, 100);
StartPosition = FormStartPosition.Manual;
Text = "bug #81422";
Load += new EventHandler (MainForm_Load);
}
示例3: Items_Should_Be_Created_Using_ItemTemplate_If_Present
public void Items_Should_Be_Created_Using_ItemTemplate_If_Present()
{
TreeView target;
var root = new TestRoot
{
Child = target = new TreeView
{
Template = CreateTreeViewTemplate(),
Items = CreateTestTreeData(),
ItemTemplate = new FuncTreeDataTemplate<Node>(
_ => new Canvas(),
x => x.Children),
}
};
ApplyTemplates(target);
var items = target.ItemContainerGenerator.Index.Items
.OfType<TreeViewItem>()
.ToList();
Assert.Equal(4, items.Count);
Assert.All(items, x => Assert.IsType<Canvas>(x.HeaderPresenter.Child));
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
#region Initialize Values
Page mainPage = this.Page;
myTree = (TreeView)mainPage.FindControl("TreeView1");
NodeSelected = myTree.SelectedNode;
btnSubmit.Text = CareerCruisingWeb.CCLib.Common.Strings.TextCode(11202);
if (NodeSelected == null)
return;
if (NodeSelected.ToolTip == "Degree Requirement")
{
this.Visible = true;
lblTitle.Text = NodeSelected.Text;
strDegreeReqID = NodeSelected.Value;
strDegreeID = NodeSelected.Parent.Value;
strSchoolID = ((CareerCruisingWeb.PageBase.SuperBase)Page).SchoolID;
HiddenField strLastNode = (HiddenField)mainPage.FindControl("hdnLastNode");
if (strLastNode.Value != "DRID" + strDegreeReqID)
{
blFirstLoad = true;
strLastNode.Value = "DRID" + strDegreeReqID;
}
}
#endregion Initialize Values
}
示例5: GetTreeView
public static void GetTreeView(TreeView tv)
{
tv.Nodes.Clear();
//建立根節點
TreeNode Root = new TreeNode();
Root.Text = "Land Project";
tv.Nodes.Add(Root);//建立根节点
using (SqlConnection cn = new SqlConnection(ConnString))
{
if (cn.State != ConnectionState.Open) cn.Open();
using (SqlCommand cm = new SqlCommand(" Select Distinct Pid,Convert(Nvarchar(10),CreateTime) CreateTime From LandProject Order By CreateTime DESC", cn))
{
using (SqlDataReader dr = cm.ExecuteReader())
{
while (dr.Read())
{
TreeNode Node = new TreeNode();
Node.Text = dr["CreateTime"].ToString().Trim();
//Node.Target = "mainbottom";
//string Path = drNode["menu_addr"].ToString();
//int menusn = Convert.ToInt32(drNode["sn"].ToString());
Node.NavigateUrl = "LandProjectView.aspx" + "?Pid=" + dr["Pid"].ToString().Trim();
Root.ChildNodes.Add(Node);//建立子节点
}
}
}
}
tv.ExpandAll();
}
示例6: LoadHierarchicalXmlData
// Load hierarchical data from XML and display it in a TreeListControl
void LoadHierarchicalXmlData()
{
var treeListControl = new TreeListControl();
treeListControl.Dock = DockStyle.Fill;
treeListControl.ShowRoot = false;
treeListControl.LabelEditMode = TreeControl.LabelEditModes.EditOnF2 | TreeControl.LabelEditModes.EditOnClick;
treeListControl.NodeDataEdited += treeListControl_NodeDataEdited;
Controls.Add(treeListControl);
Assembly assembly = Assembly.GetExecutingAssembly();
string startupPath = Path.GetDirectoryName(new Uri(assembly.GetName().CodeBase).LocalPath);
var xmlPath = Path.Combine(startupPath, "CoolSUVs.xml");
var treeView = new TreeView(xmlPath, new DataEditorTheme(treeListControl.Font));
var treeControlAdapter = new TreeControlAdapter(treeListControl);
treeControlAdapter.TreeView = treeView;
treeListControl.ItemRenderer = new TreeListItemRenderer(treeView);
treeListControl.Columns.Add(new TreeListView.Column("MPG", 80));
treeListControl.Columns.Add(new TreeListView.Column("Weight", 80));
treeListControl.Columns.Add(new TreeListView.Column("AWD", 50));
treeListControl.Columns.Add(new TreeListView.Column("Color", 80));
treeListControl.Columns.Add(new TreeListView.Column("MSRP", 80));
treeListControl.ExpandAll();
}
示例7: Init
public void Init(Rect rect, BackendData backendData)
{
if (this.m_TreeView != null)
return;
this.m_BackendData = backendData;
TreeViewState treeViewState = new TreeViewState();
treeViewState.columnWidths = new float[6]
{
250f,
90f,
93f,
98f,
74f,
78f
};
this.m_TreeView = new TreeView(this.m_EditorWindow, treeViewState);
ITreeViewGUI gui = (ITreeViewGUI) new TestGUI(this.m_TreeView);
ITreeViewDragging dragging = (ITreeViewDragging) new TestDragging(this.m_TreeView, this.m_BackendData);
ITreeViewDataSource data = !this.m_Lazy ? (ITreeViewDataSource) new TestDataSource(this.m_TreeView, this.m_BackendData) : (ITreeViewDataSource) new LazyTestDataSource(this.m_TreeView, this.m_BackendData);
this.m_TreeView.Init(rect, data, gui, dragging);
this.m_ColumnHeader = new TreeViewColumnHeader();
this.m_ColumnHeader.columnWidths = treeViewState.columnWidths;
this.m_ColumnHeader.minColumnWidth = 30f;
this.m_ColumnHeader.columnRenderer += new System.Action<int, Rect>(this.OnColumnRenderer);
}
示例8: MForm9
public MForm9()
{
Text = "TreeView";
Size = new Size(250, 250);
TreeView tv = new TreeView();
TreeNode root = new TreeNode();
root.Text = "Languages";
TreeNode child1 = new TreeNode();
child1.Text = "Python";
TreeNode child2 = new TreeNode();
child2.Text = "Ruby";
TreeNode child3 = new TreeNode();
child3.Text = "Java";
root.Nodes.AddRange(new TreeNode[] {child1, child2, child3});
tv.Parent = this;
tv.Nodes.Add(root);
tv.Dock = DockStyle.Fill;
tv.AfterSelect += new TreeViewEventHandler(AfterSelect);
sb = new StatusBar();
sb.Parent = this;
CenterToScreen();
}
示例9: Tree
public Tree(string[] args)
{
Application.Init ();
store = new TreeStore (typeof (string), typeof (string));
Glade.XML gxml = new Glade.XML(null, "tree.glade", "window", null );
gxml.Autoconnect( this );
window.Resize(500, 400 );
// eventos
window.DeleteEvent += new DeleteEventHandler( Salir );
b_agregar.Clicked += new EventHandler( Agregar );
b_eliminar.Clicked += new EventHandler( Borrar );
b_limpiar.Clicked += new EventHandler( Limpiar );
b_salir.Clicked += new EventHandler( Cerrar );
// crear arbol
tv = new TreeView ();
tv.Model = store;
tv.HeadersVisible = true;
tv.AppendColumn ("Nombre", new CellRendererText (), "text", 0);
tv.AppendColumn ("Apellidos", new CellRendererText (), "text", 1);
scrolledwindow1.Add (tv);
window.ShowAll ();
Application.Run ();
}
示例10: SaveTreeView
public void SaveTreeView(TreeView treeView, string key)
{
List<bool?> list = new List<bool?>();
SaveTreeViewExpandedState(treeView.Nodes, list);
HttpContext.Current.Session[key + treeView.ID] = list;
}
示例11: Root_TreeContainerFromItem_Should_Return_Descendent_Item
public void Root_TreeContainerFromItem_Should_Return_Descendent_Item()
{
var tree = CreateTestTreeData();
var target = new TreeView
{
Template = CreateTreeViewTemplate(),
Items = tree,
DataTemplates = CreateNodeDataTemplate(),
};
// For TreeViewItem to find its parent TreeView, OnAttachedToLogicalTree needs
// to be called, which requires an IStyleRoot.
var root = new TestRoot();
root.Child = target;
ApplyTemplates(target);
var container = target.ItemContainerGenerator.Index.ContainerFromItem(
tree[0].Children[1].Children[0]);
Assert.NotNull(container);
var header = ((TreeViewItem)container).Header;
var headerContent = ((TextBlock)header).Text;
Assert.Equal("Grandchild2a", headerContent);
}
示例12: readSysTree
public void readSysTree(TreeView TV)
{
Model.SelectRecord selectRecord = new Model.SelectRecord("Menu", "", "*", "where 1=1");
DataSet set = BLL.SelectRecord.SelectRecordData(selectRecord);
if (set != null)
{
DataTable table = set.Tables[0];
TV.Nodes.Clear();
DataView view3 = new DataView(table)
{
RowFilter = "parentid=0"
};
DataView view = view3;
foreach (DataRowView view2 in view)
{
TreeNode node2 = new TreeNode
{
Text = view2["name"].ToString(),
Value = view2["id"].ToString()
};
TreeNode child = node2;
if (this.list.Contains(view2["id"].ToString()))
{
child.Checked = true;
}
TV.Nodes.Add(child);
this.AddChildNode(table, child, view2["id"].ToString());
child.ExpandAll();
}
}
}
示例13: SelectTreeNodeByNodeValue
public static void SelectTreeNodeByNodeValue(TreeView treeView, string nodeValue)
{
foreach (TreeNode rootNode in treeView.Nodes) {
bool isSelected = SelectTreeNodeByNodeValue(treeView, rootNode, nodeValue);
if (isSelected) break;
}
}
示例14: Checked
protected override bool Checked(WinForms::ToolStripMenuItem clickedItem, TreeView treeView, TreeNode clickedTn)
{
IEnumerable<IMaxNode> selNodes = TreeMode.GetMaxNodes(treeView.SelectedNodes);
return selNodes.OfType<XRefSceneRecord>()
.Any(x => x.HasFlags(this.Flags));
}
示例15: Populate
public TreeView Populate(string userId)
{
TreeView treeView = new TreeView();
IList<MenuFuncVO> menuFuncList = m_AuthService.GetTopMenuFuncNoLazy();
//var result = from data in menuFuncList
// where data.ParentMenu == null
// select data;
foreach (MenuFuncVO menu in menuFuncList)
{
TreeNode treeNode = new TreeNode(menu.MenuFuncName, "");
if (menu.SubFuncs.Count > 0)
{
foreach (MenuFuncVO subMenu in menu.SubFuncs)
{
//TreeNode subTreeNode = new TreeNode(subMenu.MenuFuncName, subMenu.Id.ToString());
TreeNode subTreeNode = new TreeNode(subMenu.MenuFuncName, subMenu.MainPath);
//subTreeNode.NavigateUrl = "~/" + subMenu.MainPath;
treeNode.ChildNodes.Add(subTreeNode);
}
}
treeView.Nodes.Add(treeNode);
}
return treeView;
}