Hi,
Instead of making use of the
SelectedNodeChanged
&
TreeNodeCheckChanged
events, try the
TreeView.AfterCheck
Event:
More Information. I made use of that event in one of my projects to accomplish the exact same thing and it worked for me...
[UPDATE]
Okay, the
TreeView.AfterCheckEvent
event is located within the Events list of the Treeview. The first event under the 'Behaviour' section.
this.treeView1.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterCheck);
private void treeView1_AfterChecktreeLocation_AfterCheck(object sender, TreeViewEventArgs e)
{
....
}
-- OR --
private void CheckAllChildNodes(TreeNode treeNode, bool nodeChecked)
{
foreach(TreeNode node in treeNode.Nodes)
{
node.Checked = nodeChecked;
if(node.Nodes.Count > 0)
{
this.CheckAllChildNodes(node, nodeChecked);
}
}
}
private void node_AfterCheck(object sender, TreeViewEventArgs e)
{
if(e.Action != TreeViewAction.Unknown)
{
if(e.Node.Nodes.Count > 0)
{
this.CheckAllChildNodes(e.Node, e.Node.Checked);
}
}
}
-- OR --
If your'e making use of ASP.NET, then have a look at the following post:
Check all related childNodes
[UPDATE]
Kind regards,