petre ricardo

petre ricardo

  • NA
  • 194
  • 0

I cannot check all the ChildNodes in my ParentNode?

Nov 1 2009 1:47 AM

hi,
I ahve create a TreeView Control wiht check boxes:
 
I have created a parent Tree Node as:
 

TreeNode parentNode = new TreeNode("Departments");

 
Then i have added four childNodes
 

for(int i=0; i< 4; i++)
{
   TreeNode childNode = new TreeNode(i.ToString());
   parentNode.Nodes.add(childNode);
}
 
TreeViewControl.Nodes.add(parentNode)

 
Then i need to check all the childsNodes if parentNode is Checked so....
 

 
private void tvDepartments_AfterCheck(object sender, TreeViewEventArgs e)
{
if (e.Node.Name.ToString() == "parentNode")
{
foreach (TreeNode item in e.Node.Nodes)
{
item.Checked =
true;
}
}
}

 
The problem is that the control woudlnt go into the if statement... How do i fix this?
TY

Answers (2)