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

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.

commented: good +11

Thanks

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.