[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2957
  • Last Modified:

How do I use FirstDisplayedScrollingRowIndex 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


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

Open in new window

0
BIGZIPZ1
Asked:
BIGZIPZ1
1 Solution
 
JeffvClaytonCommented:
 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)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now