kiranreddys.com
Kiran's personal website
Blog   Forums   Sitemap   Links   
 
 
 
Knowledgebase
 
Home
Knowledge base home, and site home.
Categories
List of all Knowledge base categories.
Glossary
An alphabetical list of technical terms.
Contact Me
Contact me for knowledge base questions
My Blog
My articles, white papers, ideas and thoughts.
 

 
 


Populating tree nodes of a Tree view control in C#.NET

//How can I populate tree nodes of a Tree View Control in C#.NET?

//Code by Kiran Reddy
//TreeViewNodes
//First add one parent node to the Tree View control in its properties, select the parent node, to add child nodes to the Tree view add following code to button click events

TreeNode tvnode = new TreeNode("your_Node_Name");
treeView1.SelectedNode.Nodes.Add(tvnode);
treeView1.ExpandAll();
if(treeView1.SelectedNode.Nodes.Count > 1 && treeView1.SelectedNode.ForeColor != Color.Blue)
treeView1.SelectedNode.ForeColor = Color.Green;

//Add siblings to treeview

TreeNode tvnode = new TreeNode("your_Node_Name");
tvnode.ForeColor = Color.Brown;
treeView1.SelectedNode.Parent.Nodes.Add(tvnode);

//Delete selected node
treeView1.SelectedNode.Remove();

Category: C#.NET - Windows,

User Comments

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment







CAPTCHA Image
Security code




Home | About Me | Products | Support | Contact Me | Knowledge base | Forums | Blog | Site map | Site Search | Subscribe | Links | News

Travel | Guest Book | All Pages | History | Site Calendar | Recipes | Ex-Rates | UK Stuff | Downloads | Telugu Stuff | Tell a Friend | Feedback

www.kiranreddys.com
Terms of Use
Site contents Copyright © 2008-2009 Kiran Reddy. All rights reserved.