I found a lot about treeview and checkboxes in treeviews...
but one thing seems to be undiscussed.
I have my treeview like
[x] Foo
L [x] One
L [x] Two
L [x] Three
[x] Bar
L [ ] One
L [x] Two
L [x] Three
[ ] Hello
L [ ] One
L [ ] Two
L [ ] Three
Now when I check my parent checkbox e.g. Foo than all child get selected. Also they get deselected by unchecking Foo. To do this I have this Method
private void TreeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
foreach (TreeNode childNode in e.Node.Nodes)
{
childNode.Checked = e.Node.Checked;
}
}
I tried a lot with using count and others but could not achive what i'm trying to achive.
So what I want is, when I check Two in TreeNode Hello than Hello should get checked. Without checking One and Three. Check-/Unchecking Hello should select/deselect all childs.
Is this even possible?
Because when Hello gets checked, it fires the TreeView1_AfterCheck-event!
So my Question actually is:
Can I achive the above described behavior?
Ask me if something is unclear.
Aucun commentaire:
Enregistrer un commentaire