We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to set focus

Hello
I dont know how to set focus to gridtreeview element;
I have a loop in collection of binded elemnt(ItemsSource) in view model.
I found searching element but i dont know how to set focus.
private void SetFocus(ObservableCollection findItems, string itemToFocus)
{
foreach (var item in findItems)
{
if (item.ID == itemToFocus)
{
//here i found the node and i neeed to set focus in treegridview to him
}
else
{
SetFocus(item.Child, itemToFocus);
}
Goodbye



1 Reply

JG Jai Ganesh S Syncfusion Team April 26, 2016 03:41 AM UTC

Hi Lukasz, 
 
You can achieve your requirement for select the specific node by using the below code example,

Code Example [C#]:

 

  private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            foreach(var node in treeGrid.InternalGrid.Nodes) 
            { 
                for (int i = 0; i < node.ChildNodes.Count;i++ ) 
                { 
                    if ((node.ChildNodes[i].Item as EmployeeInfo).EmpID == 1008) 
                    { 
                        if (node.HasChildNodes) 
                        { 
                            node.Expanded = true; 
                        } 
                         
                        node.ChildNodes[i].IsSelected = true; 
                        treeGrid.InternalGrid.SelectedNodes.Add(node); 
                        
                    } 
                } 
                 
            } 
            treeGrid.InternalGrid.ReloadNodes(); 
 
         } 
 
Regards, 
Jai Ganesh S 


Loader.
Live Chat Icon For mobile
Up arrow icon