The first experience building a TreeView will take ages, the next not so long, and the next after that will be quick. Once you know the a) objects, b) various constructors, c) properties and d) events its very easy.
Creating hierarchy of nodes: TreeNode main = new TreeNode(); main.Name = "main"; main.Text = "main"; main.Nodes.Add(someNode);
Constructors from MSDN:
The TreeNode constructor has six different overloads.
http://msdn.microsoft.com/en-us/library/system.windows.forms.treenode.treenode.aspx
Notice how everything on MSDN is stored on ASPX (xhtml) pages.
Favorite Overloads TreeNode("text"); TreeNode("text", childNodeArray)
To get selected data: main.SelectedNode.Text
How do you reverse an array of TreeNodes? Array.Reverse(treeNodeArray);
AfterSelect event handler: processes a node selection. To process nodes of only a certain depth do: if (e.Node.Level == x) { do_something(); } where e is a TreeViewEventArgs object.
Remember how to program this using JTrees in Java?
Java is IRON, C# is STEEL.
No comments:
Post a Comment