Can anybody tell me how to handle mouse scroll event(vertical scroll) 开发者_如何学Goin 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?
Use the FirstDisplayedScrollingRowIndex property.
Use DataGridView Scroll event
if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
{
int i = dataGridView1.FirstDisplayedCell.RowIndex;
}
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
精彩评论