• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Sending Up and Down Arrows to DataGridView

HLeyes

Member
Joined
Feb 10, 2016
Messages
12
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
498
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.
 
Top Bottom