DataGrid and Arrows

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
 
R

raj

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top