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

Setting Checked Nodes

1 Answer 85 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
James B.
Top achievements
Rank 1
James B. asked on 18 Jan 2011, 04:06 AM
I'm trying to set checkboxes as checked on a radtreeview with tristatecheckboxes set to true. Using the code below works when there is only one level, but having trouble where there are 3 levels (passing in a comma delimted string of checkbox values).

protected void selectCheckedNodes(RadTreeView treeView, string val)
        {
            if (!string.IsNullOrEmpty(val))
            {
                string[] cbarray = new string[] { "" };
                cbarray = val.Split(',');

                foreach (string i in cbarray)
                {
                    
                    RadTreeNode obj = treeView.Nodes.FindNodeByValue(i);
                    if (obj != null)
                        obj.Checked = true;
                }
            }
        }

Can someone show me how to iterate thru the treeview to check the approriate nodes? I am not passing in the parent categories, just the specific nodes I want checked. Thanks!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Jan 2011, 11:08 AM
Hello James,


You could use the following code to access corresponding node at runtime.
             RadTreeNode obj = treeView.FindNodeByValue(i);


Another option is iterating through all the nodes in treeview and check for the Value to get the required.
foreach (RadTreeNode node in RadTreeView1.GetAllNodes())
{
    if (node.Value== "Car") // condition
    {
        node.Selected = true;
        break;
    }
}



-Shinu.
Tags
TreeView
Asked by
James B.
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or