Thursday, 3 May 2007

Checking all child nodes of a treeview when parent node checked

Checking all child nodes of a treeview when parent node checked using C# (c-sharp)
It will also expand the parent node to show the children.


private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Checked)
{
foreach (TreeNode nd in e.Node.Nodes)
{
nd.Checked = true;
}
//Expand tree node now
e.Node.Expand();
}

}

It's easy guys isn't it?





No comments: