Z
Z
ZmeuSnake2016-06-26 15:27:42
Programming
ZmeuSnake, 2016-06-26 15:27:42

How to prevent dataGridView from scrolling with mouse wheel?

There is this code:

int k = 0;
...
void dataGridView1_MouseWheel(object sender, MouseEventArgs e)
{
if (e.Delta < 0 && k < 15) //если колесо мыши на себя
    k++;
else
{
//если прокрутил на 15 строчек вниз, то дальше нельзя.
 //Тут нужно запретить дальнейшую прокрутку грида.
}
}

How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanostee, 2016-06-26
@ZmeuSnake

Try to set the value of the DataGridView property in else. FirstDisplayedScrollingRowIndex (Index of the first displayed row). To get the number of rows to display, use the DataGridView. DisplayedRowCount .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question