DataGrid and Arrows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have DataGrid and i want to use the arrows to navigate up and down between
the lines. i also want that each row i'm in, will be marked (as in
DataGrid.Select(row_number)). When my form is loaded, my focus is on a
textbox i have, and what i want to do is that if i press the arrows keys the
focus will be on the dataGrid (on the next row) and while i'll navigate with
arrows, the row i will be in will be totaly marked.

how can i do that?

Thanks,
Gidi
 
On the form turn on the KeyPreview under the properties window

then add evenhandler for keypress to the form, compare the keycode to see if
it was an arrow (KeyChar) if so then move focus to the datagrid.
datagrid already handles arrow keys so you don t have to worry about that.
To select the row: use datagrid.RowIndex to get the current row in the
keypress event for the datagrid.
then use datagrid.Selectrow(datagrid.RowIndex)

u didn t think i was gonna code it for you did u? :)

have fun.... BTW MSDN is your friend
 
Back
Top