Focus Issue

Hi,

I have a TextBox which should always get focused after any actions, for example filtering or sorting. But after activating one filter, the datagrid will refresh and get focused, namely my TextBox will lost focus. But i need it to get focused. Could you help me? Thanks a lot!

Best Regards
Wenkai

1 Reply

DY Deivaselvan Y Syncfusion Team October 12, 2018 04:05 AM UTC

Hi Wenkai 

Thank you for contacting Syncfusion support.

 
We have analyzed your query to focus TextBox after performaing data operations in SfDataGrid. By default, focus will set to the currently operating control. To achieve your requirement to focus TextBox after filtering and sorting, you can manually set the focus to textbox using the events of those operations as like below code snippet 

this.sfDatagrid.View.CollectionChanged += View_CollectionChanged; 
 
private void View_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) 
{ 
     this.AssociatedObject.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, new Action(() => 
    { 
          TextBox textBox = Application.Current.MainWindow.FindName("textBox") as TextBox; 
 
          if (textBox != null) 
          { 
               textBox.Focus(); 
          } 
    })); 
             
} 

Please find the sample for the same and let us know if this helps you.
http://www.syncfusion.com/downloads/support/forum/140309/ze/WPF2073658178

If we misunderstood on your requirement then, kindly revert us with more details along with the sample and screenshot or video to illustrate your requirement, thereby we could analyze further and update you with the appropriate solution at the earliest. 

Please let us know if you have any other questions.

 
Regards, 
Deivaselvan 


Loader.
Up arrow icon