Alex D.
Alex D.

Reputation: 31

Windows Forms 3.5 how to scroll a DataGridView vertically via code

The client wants to be able to type a letter and have the system scroll the DataGridView such that the first row with a cell that matched the letter will scroll to the top of the DataGridView

Any suggestions will be appreciated

Upvotes: 3

Views: 782

Answers (1)

V4Vendetta
V4Vendetta

Reputation: 38200

I am not sure how you will be able to lookup efficiently for the getting the row which matches the letter you have. But you can have a look at these properties which would help you setting the focus

dataGridView1.FirstDisplayedScrollingRowIndex //set the rowindex

In case you have a horizontal scroll also set this value

dataGridView1.FirstDisplayedScrollingColumnIndex

I believe you would be looping through, so you should be able to set these values and again set the CurrentCell as the one you found.

Hope this helps

Upvotes: 4

Related Questions