Preventing Child Nodes from Being Automatically Checked
In This Topic
When check boxes are utilized in a C1TreeView, clicking a parent node will automatically check all of its child nodes as well. To prevent this, you can set the C1TreeView's AutoCheckNodes property to False.
In this tutorial, you will create a C1TreeView control with one parent node and two child nodes. You will change the nodes to check boxes and then set the AutoCheckNodes property to False so the child nodes' Checked property settings will be independent of its parent node's Checked property setting.
Complete the following:
- Click the Source tab to switch to Source view.
- Add the following markup between the <cc1:C1TreeView> tags:
Markup |
Copy Code
|
<Nodes>
<cc1:C1TreeViewNode runat="server" Text="Parent">
<Nodes>
<cc1:C1TreeViewNode runat="server" Text="Child 1">
</cc1:C1TreeViewNode>
<cc1:C1TreeViewNode runat="server" Text="Child 2">
</cc1:C1TreeViewNode>
</Nodes>
</cc1:C1TreeViewNode>
</Nodes>
|
- This markup creates a parent node with two child nodes.
- Enable the check boxes by adding ShowCheckBoxes="True" to the <cc1:C1TreeView> tag.
- Press F5 to run the project and complete the following to see how the check boxes behave by default:
- Expand the Parent node to reveal the TreeView hierarchy.
- Click the Parent check box and observe that the child nodes are automatically selected.
- Terminate the program.
- Click Design tab to enter Design view.
- In the Properties window, select C1TreeView1 from the drop-down list and then set the AutoCheckNodes property to False.
- Press F5 to run the project and complete the following to see how the check boxes behave when the nodes are no longer auto-checked:
- Expand the Parent node to reveal the TreeView hierarchy.
- Check the Parent check box and observe that the child tabs don't get checked automatically.
If you check the
Child 1 check box and leave the
Child 2 check box, you'll notice that the
Parent check box contains an "indeterminate" mark. If you want to prevent this from happening, set the
C1TreeView control's
AllowTriState property to
False.
See Also