Question : How do I use FirstDisplayedScrollingRow<wbr />Index on the fly?

Hi there, I have some code below which will make the first displayed row in my datagrid whatever row my mouse is currently clicked on.

Is there a way to change it so that "row" variable could contain a number that I choose so that, say, when I click Button3 it always sets "row" as the tenth row in the datagrid even though no row is selected by the mouse etc?

I tried changing to Dim row as Integer = "10" but I get an error that CurrentRow cannot be set to an integer.

Thanks everyone

Code Snippet:
1:
2:
3:
4:
5:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim row As DataGridViewRow
        row = JackBennyDataGridView.CurrentRow
        JackBennyDataGridView.FirstDisplayedScrollingRowIndex = JackBennyDataGridView.Rows.IndexOf(row)
    End Sub

Answer : How do I use FirstDisplayedScrollingRow<wbr />Index on the fly?

 Dim iRow As Integer
        iRow = 10

       JackBennyDataGridView.FirstDisplayedScrollingRowIndex = iRow

This should work without any problem. I notice you have "10" instead of 10  (ie. there should be no quotes)
Random Solutions  
 
programming4us programming4us