I have added a RadTreeView Control in run time. I am changing the backcolor of the selected node usnig
treeView_Selected event. But when I select another node , the colour of previously selected node also remains the same (I want to change the back colour of this previously selected node).
Does any one have any idea, how to achieve it?
7 Answers, 1 is accepted
You should be able to change the color of the previous selected node by using the Selecting event. This event is called before the currently selected node is changed.
I hope this helps.
Thanks for your reply.
But this solution is not working for me.
I am getting radTreeView1.SelectedNode as null in radTreeView1_Selecting event. Another thing is that i am creating radTreeView control in run time, so I don't have access of the instance of radTreeView control in radTreeView1_Selecting event. So Iam using e.Node.TreeView.SelectedNode in the radTreeView1_Selecting event, which i think is same as radTreeView1.SelectedNode.
Thank you for writing. Just keep a reference to the previously selected node and change its back color as needed. Write again if you need further assistance.
Could you please provide some code sample regardning how to keep the refrence of selected node? Please keep in mind that treeview is created in run time not in design time.
Thanks in advance....
I am unsure of why the way you are accessing the TreeView isn't working.. However, you can actually access the RadTreeView in the selecting event by casting the sender parameter as a RadTreeView. Here is an example of creating a RadTreeView control at runtime with support for the Selected and Selecting events.
I hope this helps.
Thank you for writing.
I am not exactly sure of the version you are using. You can try handling the SelectedNodeChanging and SelectedNodeChanged events and keep track of track of the selected nodes. At the same time you would be able to change the required back color:
I hope this helps. Please let me know if you need further assistance.
Telerik by Progress