Reputation: 1051
Can anybody tell me how to handle mouse scroll event(vertical scroll) in a datagrid? If i scroll the mouse scroller, then datagrid will scrolls. I want to get rowIndex of datagrid's row that is displayed at the top when scroll the grid vertically.
can any body help me?
Upvotes: 2
Views: 2890
Reputation: 15344
Use DataGridView Scroll event
if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
{
int i = dataGridView1.FirstDisplayedCell.RowIndex;
}
Upvotes: 1
Reputation: 3731
You can use MouseWheel and/or PreviewMouseWheel events of the DataGrid MouseWheel fires when the user ended scrolling, whilst the Preview one fires when the user is about to scroll
Concerning the topmodt drawn index, i cant say anything :/
Hope it helps :p
Upvotes: 0