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

Change focus on node select

1 Answer 96 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 10 Mar 2015, 03:16 PM
Hello,

I want to select a control in my form when the user selects a node.
This works when selecting the node with the keyboard but when i select a node with the mouse, the node gets the focus after the SelectedNodeChanged event.
Is there any way to tell the Treeview not to steal the focus?

1 Answer, 1 is accepted

Sort by
0
Todor Vyagov
Telerik team
answered on 12 Mar 2015, 03:30 PM
Hello Alexander,

Thank you for writing.

When you click the node of RadTreeView as you mentioned the focus is set after the SelectedNodeChanged event is fired. To set the focus to other control after the mouse is clicked you can subscribe to the MouseUp event.
private void radTreeView1_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
{
    string nodeText = e.Node.Text;
    SetFocusToControl(nodeText);
}
 
private void radTreeView1_MouseUp(object sender, MouseEventArgs e)
{
    if (this.radTreeView1.SelectedNode == null)
    {
        return;
    }
    string nodeText = this.radTreeView1.SelectedNode.Text;
    SetFocusToControl(nodeText);
}
 
private void SetFocusToControl(string nodeText)
{
    if (nodeText == "RadButton")
    {
        this.radButton1.Focus();
    }
    else if (nodeText == "RadDropDownButton")
    {
        this.radDropDownButton1.Focus();
    }
}

I hope this information helps.

Regards,
Todor Vyagov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Treeview
Asked by
Alexander
Top achievements
Rank 1
Answers by
Todor Vyagov
Telerik team
Share this question
or