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

SelectedNodeChanged not deselecting node

1 Answer 76 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Ralph
Top achievements
Rank 2
Ralph asked on 12 Feb 2010, 12:44 PM
Hi

I use RadControls for WinForms Q3 2009 SP1.

In order to add a node to an existing node I need to know what the last selected node was, and SelectedNodeChanged works perfectly for this.

The problem is when I want to add a node to the root of the TreeView, I click on the TreeView itself (not on a node) and SelectedNodeChanged is *not* fired with RadTreeViewEventArgs.Node = null.  Any idea how I can get around this?

Thanks
Ralph

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 12 Feb 2010, 03:01 PM
Hello Ralph,

You can set the SelectedNode to null when no node is clicked:

void tv_MouseDown(object sender, MouseEventArgs e)
{
    RadTreeView tv = (RadTreeView)sender;
    RadElement elementUnderMouse = tv.ElementTree.GetElementAtPoint(e.Location);
 
    if (!(elementUnderMouse is TreeNodeUI))
    {
        tv.SelectedNode = null;
    }
}

Please write again if you have other questions.

Regards,
Victor
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Treeview
Asked by
Ralph
Top achievements
Rank 2
Answers by
Victor
Telerik team
Share this question
or