TreeView Control

  • Thread starter Thread starter raksdesai
  • Start date Start date
R

raksdesai

Hello,

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.

Regards,
Rakshit Desai
 
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);
}
}
#endregion
 
Back
Top