This is a migrated thread and some comments may be shown as answers.

Display Checkboxs On Leaf Nodes Only

1 Answer 102 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Veteran
Iron
Andrew asked on 26 Nov 2008, 07:11 PM
what is the bestway to display checkboxs on leaf nodes only

is there a property like "showcheckboxes" in the standard treeview control from MS

1 Answer, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 27 Nov 2008, 11:22 AM
Hello Andrew,

You should set CheckBoxes property to true in order to have checkboxes. The following code snippet demonstrates how to show checkboxes only for leaf nodes:

 protected void checkOnlyLeafNodes(RadTreeNode node)  
    {  
        if (node.Nodes.Count != 0)   
        {  
            node.Checkable = false;  
            foreach (RadTreeNode node1 in node.Nodes)  
                checkOnlyLeafNodes(node1);  
        }  
    } 

and you can call it in Page_Load event for every root node:

foreach (RadTreeNode node in RadTreeView1.Nodes)  
            checkOnlyLeafNodes(node); 

I hope this helps.

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Andrew
Top achievements
Rank 1
Veteran
Iron
Answers by
Yana
Telerik team
Share this question
or