Grid does not auto scroll to row when selected

4 posts, 1 answers
  1. Bob
    Bob avatar
    41 posts
    Member since:
    Mar 2012

    Posted 14 May 2012 Link to this post

    When I search for an item in a row, the grid does not scroll down to the selected row.

    The row is selected, but I have to manually scroll down to the selected row.

    I have AutoScroll = true

    Thanks

    If filterTextBox.Text <> "" Then
        For Each row As GridViewDataRowInfo In LotDetailsDataGrid.Rows
            If (filterTextBox.Text.Equals(row.Cells("ISBN_13").Value.ToString)) Then
                row.IsSelected = True
                Exit For
            End If
        Next
    End If
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 17 May 2012 Link to this post

    Hello Bob,

    Thank you for writing.

    The AutoScroll property comes from ScrollableControl and it is not intended for the desired functionality. More information about it can be found here: http://msdn.microsoft.com/en-us/library/system.windows.forms.scrollablecontrol.autoscroll.aspx.

    To achieve the desired functionality you need to use the ScrollToRow method of the TableElement:
    radGridView1.TableElement.ScrollToRow(radGridView1.Rows[30]);

    I hope this helps. Let us know if you have any other questions.

    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. Bob
    Bob avatar
    41 posts
    Member since:
    Mar 2012

    Posted 17 May 2012 Link to this post

    Thank you!

    That was exactly what I was looking for.

    As a side note, when the grid scrolls to the specific row it is not highlighted.  So if anyone is wondering, I added:

    radGridView1.Rows(row.index).IsSelected = True

    and the row was nicely highlighted for me as well.

    Thanks
  4. Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 22 May 2012 Link to this post

    That is correct. The method mentioned only scrolls the grid to the specified row. If you want the row to be selected you should set its IsSelected property. If you want it current, set the IsCurrent property.

    All the best,
    Stefan
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Back to Top