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

Select first row after getting focus


I try to use sfDataGrid as a search windows. I have a simple form with a TextBoxExt and a sfDataGrid.
When typing a value in the TextBox, the grid is filtered by that text.

When one row is left, I want only press enter to select the first value of the row and send it back as my key.
Or when there are multiple rows left, I want to press the down arroy (or tab) to left the TextBox and enter the sfDataGrid.
So I can use the down arrow to go to the record I want, press enter and send the first value back as my key.

It is working now with the mouse. After filtering, I can double click on a row and send back the first value of the row.

And what is working also is after filtering, I click with the mouse on a row, then go with arrow key to the record of my choose, press enter.

What I can not getting work is give the sfDataGrid the same focus as clicking with the mouse on the grid.

With sfDataGrid.Focus() and sfDataGrid1.SelectRows(1,1) or sfDataGrid.SelectCells(record, column), I can not use arrow keys to go to the other records.

So my question is:
How can I set the same focus programmaticaly as clicking with the mouse on a cell.

Thank You,


4 Replies

GS Gerrit Snel December 25, 2018 09:50 AM UTC

Solved it:

            if(e.KeyCode == Keys.Down)
                if(sfDataGrid1.View.Records.Count > 0)

JN Jayaleshwari N Syncfusion Team December 26, 2018 11:44 AM UTC

Hi Gerrit, 
Thanks for the update. 
Please get in touch if you would require further assistance. 
Jayaleshwari N. 

ZE Zafer Ergül December 17, 2021 08:17 AM UTC

not working 

MA Mohanram Anbukkarasu Syncfusion Team December 20, 2021 12:30 PM UTC

Hi Zafer, 
The mentioned code snippets will work property to move focus to SfDataGrid. Please revert to us with more detail about your scenario and your requirement. We will check and update with details based on your scenario.  
Mohanram A. 

Live Chat Icon For mobile
Up arrow icon