Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Forms 3.5 how to scroll a DataGridView vertically via code

Tags:

datagridview

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

like image 585
Alex D. Avatar asked May 23 '26 08:05

Alex D.


1 Answers

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

like image 134
V4Vendetta Avatar answered May 26 '26 18:05

V4Vendetta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!