Setting a current TreeNode in the Telerik RadTree control

I have started working with the Telerik RadControls for ASP.Net AJAX recently and decided to start posting some helpful code snippets that I keep using.

 

 

This first snippet allows you to set a particular Tree Node to be the selected one. In the code I am passing in a specific string value that corresponds to one of the tree’s node value properties.  This then returns an instance of the particular Node which then exposes a Selected attribute.

On thing to be aware of is that the Tree control itself has a SelectedNode (RadTreeView1.SelectedNode) property but this is a read only attribute to get the currently selected node, not an exposed attribute for setting it.

RadTreeNode node = RadTreeView1.FindNodeByValue(“Node123”);
if (node != null)
{
node.Selected = true;
}

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!