Click here to Skip to main content
15,847,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dgv in a form having a number of rows. I have next and previous buttons to move to the respective rows in the dgv. The next and previous are working correctly. The dvg shows 10 rows at a time. When i select the 11th or the upcoming row we can not see that row. So how can i scroll to that row to see it selected?
I think someone can help me.Thanks in advance..
Updated 22-Aug-21 0:12am

if i is selected row in dataGridView1 and j is selected column , try :
dataGridView1.FirstDisplayedScrollingRowIndex =i;

dataGridView1.CurrentCell = dataGridView1[j,i];
Share this answer
Try DataGridView.FirstDisplayedScrollingRowIndex.
Share this answer
Shift in the column in from left side as requried to show it
public static bool ScrollToColumn(DataGridViewColumn col) {
    if (col.Visible && col.Width > 0) {
        var dgv = col.DataGridView;
        int colRight = 0;
        foreach (DataGridViewColumn _c in dgv.Columns) {
            colRight += _c.Width;
            if (_c == col) break;
        var delta = colRight - dgv.Width;
        if (delta > 0) {
            dgv.HorizontalScrollingOffset = delta;
            return true;
    return false;

Share this answer
Richard Deeming 23-Aug-21 4:51am    
What precisely does code for scrolling to a COLUMN have to do with an already-solved question about scrolling to a ROW?

If you're going to add a new answer to such an old question, make sure you have read and understood the question first, and that your solution will add something new to the discussion.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900