0

I have a datagridview that has 65 rows, so it has a vertical scroll bar. I also have a print button on the same form that will print the datagridview. What I'm trying to do is have the print button disabled until the user scroll to the button of the datagridview. the problem is I'm not sure how to accomplish this. I have a feeling it can be done with the verticalscrollbaroffset property of the datagridview, but I'm not entirely sure. Any help and example code would be greatly appreciated.

CaffeinatedMike
  • 1,537
  • 2
  • 25
  • 57

1 Answers1

3

You could take advantage of the fact that a row is only painted when it is scrolled into view. Which makes the RowPrePaint event useful to detect this:

    private void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) {
        if (e.RowIndex == dataGridView1.Rows.Count - 1) button1.Enabled = true;
    }
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536