Sending Up and Down Arrows to DataGridView

HLeyes

Member
Joined
Feb 10, 2016
Messages
15
Programming Experience
10+
I have a form with a textbox and a datagridview. As I type in the textbox, it filters a list of vendors and fills the grid with those vendors that start with whatever has been entered into the text box.

For example, I type in "b" in the textbox, and the grid fills with the vendors that start with "b". I can continue to type in an "a", and it will show the vendors that start with "ba".

That's all good. I want to keep the focus on the textbox so the user can continue typing and searching, but I want to be able to hit the up- and down- arrows while in the textbox and have it scroll up and down in the grid, the same as when the focus is on the grid, and the up and down arrows highlight the next or previous row.

Can someone direct me to a procedure that would do that?

Thanks in advance,

HLeyes
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
515
Location
Norway
Programming Experience
10+
Use the KeyDown event of textbox and check e.KeyCode. For up/down key set e.Handled to True, this will prevent scrolling left/right in text. Then you can set FirstDisplayedScrollingRowIndex property of DataGridView accordingly, respecting upper/lower limit of RowCount.
 

HLeyes

Member
Joined
Feb 10, 2016
Messages
15
Programming Experience
10+
JohnH - thanks for your help and reply!

HLeyes
 
Top Bottom