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

SearchPanel Focus

3 Answers 260 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kieron
Top achievements
Rank 1
Kieron asked on 27 Jul 2016, 07:55 AM

Hi,

I've enabled the search panel of a grid, the grid is the only control on a form and I want the initial focus to be in the textbox of the search panel when the user opens the form, how do I go about achieving this?

Thanks.

 

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 27 Jul 2016, 02:22 PM
Hello Kieron,

The desired behavior can be achieved by handling RadGridView's Loaded event and setting the focus to the TextBox element of the GridViewSearchPanel, like so:

public MainWindow()
{
    InitializeComponent();
    this.clubsGrid.Loaded += ClubsGrid_Loaded;
}
 
private void ClubsGrid_Loaded(object sender, RoutedEventArgs e)
{
    var searchPanel = (sender as RadGridView).ChildrenOfType<GridViewSearchPanel>().FirstOrDefault();
    var textBox = searchPanel.ChildrenOfType<TextBox>().FirstOrDefault();
    textBox.Focus();
}

Please let me know if such an approach would work for you.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Swapnil
Top achievements
Rank 1
answered on 09 Jul 2019, 01:41 PM

Hi,

Following on the above, we would like to keep the focus on the textbox once the user has hit enter; i.e. once the search results are populated, the focus should go back to the textbox. We have tried using the above but to no avail. 

Please suggest a solution. Let me know if you need any more information.

Regards,

Swapnil

0
Dilyan Traykov
Telerik team
answered on 10 Jul 2019, 02:11 PM
Hi Swapnil,

I've prepared a small sample project where the TextBox in the search panel does not lose the focus once the Enter key is pressed. Can you please have a look and let me know how this differs from the setup you have at your end?

I will be awaiting your reply.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Kieron
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Swapnil
Top achievements
Rank 1
Share this question
or