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.
Unfortunately, activation email could not send to your email. Please try again.

How to set focus

Thread ID:

Created:

Updated:

Platform:

Replies:

123807 Apr 22,2016 10:04 AM Apr 25,2016 11:41 PM WPF 1
loading
Tags: GridTreeControl
lukasz.szeszol
Asked On April 22, 2016 10:04 AM

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



Jai Ganesh S [Syncfusion]
Replied On April 25, 2016 11:41 PM

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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;