954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

tree control view with check box

Hello There,

Im trying to create tree control view with check box in the nods.
but i dont know how to add the check box to the nods

here is the code:

public Form1()
{
InitializeComponent();
TreeNode tn = new TreeNode("x");
tn.ForeColor = Color.Blue;
TreeNode tn1 = new TreeNode("Y");
tn1.ForeColor = Color.Blue;
TreeNode tn2 = new TreeNode("T");
tn2.ForeColor = Color.Blue;
treeView1.Nodes.Add(tn);
treeView1.Nodes.Add(tn1);
treeView1.Nodes.Add(tn2);

treeView1.LabelEdit = true;

}
How can i add the check boxes to the nods X,Y,T



Thanks ahead

kobi
Junior Poster in Training
57 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

First of all it is Node not Nod.

the only way to add check boxes to the node tree is by specifying it on the TreeView object itself, thus all of the nodes will have checkboxes.

but in your example it would be

treeView1.CheckBoxes = true;


another method (if you are seeking to only have it on a few and not the entire tree) is to use an image list and keep track of which nodes are visually marked with your custom check or not.

Killer_Typo
Master Poster
781 posts since Apr 2004
Reputation Points: 152
Solved Threads: 39
 

Thanks

kobi
Junior Poster in Training
57 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

any idea how to add checkbox to treeview in smartphone since it does not support checkboxes in the treeview by default

coder_guru
Newbie Poster
1 post since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You