select the row by up and down arrow key?

Deva

Member
Joined
Feb 10, 2021
Messages
18
Programming Experience
1-3
1622875742232.png


i want select the row by up and down arrow key without clicking mouse
and with input textbox by a keydown method
please help me in vb.net coding
 
I will suggest that you handle KeyDown event for textbox, here you can check e.KeyCode for Up/Down navigations keys.
You should also set e.SuppressKeyPress to True in this case to avoid default navigation in text, it would be confusing if this happens also when DataGridView is navigated.
For DataGridView you can get CurrentRow.Index, and use Rows.GetNextRow/GetPreviousRows method to get new index, notice it will be -1 if there is no next/previous row. Then you can change CurrentCell accordingly.
 
For DataGridView you can get CurrentRow.Index, and use Rows.GetNextRow/GetPreviousRows method to get new index, notice it will be -1 if there is no next/previous row. Then you can change CurrentCell accordingly.
If the grid is bound to a BindingSource, which it generally ought to be, then you can call MoveNext and MovePrevious.
 

Latest posts

Back
Top