TreeView Control




I know its forum about WindowsForms But i still want to know whether
any of you have the solution of my problem?

Problem Statement:
How to check / uncheck ASP.NET 2.0 TreeView Control's leaf checkbox so
that only one leaf node is selected?

if user check another value in child node, the previous checked node
will being unchecked and newly checked node will be displayed.

Rakshit Desai



Robbe Morris - MVP C#

Use recursion to iterate through the branch and
act accordingly. Here is a small sample that you
can modify.

#region Set Node Checked State
/// <summary>
/// Recursively sets the checked state of this node and all
/// of its child nodes to the passed in desired check state.
/// </summary>
public static void SetNodeCheckedState(TreeNode treeNode,
bool nodeChecked)

treeNode.Checked = nodeChecked;

foreach (TreeNode node in treeNode.Nodes)
SetNodeCheckedState(node, nodeChecked);

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads