Serialcoder en Français Serialcoder in English
TEL : +33 (0)9 72 13 15 17

Windows Forms FAQ resources

5. Windows Forms Datagrid

5.73 After scrolling with the mouse wheel on a selected row in a DataGrid I cannot get it back into view. Is there a work around?


When you select a row in the DataGrid and scroll it out of view using the mouse wheel, you cannot get it back into view. The following is a workaround posted by one Windows Forms User:


[C#]
this.dataGrid1.MouseWheel+=new MouseEventHandler(dataGrid1_MouseWheel);

private void dataGrid1_MouseWheel(object sender, MouseEventArgs e)
{
     this.dataGrid1.Select();

}

[VB.NET]
AddHandler Me.dataGrid1.MouseWheel, addressof dataGrid1_MouseWheel

Private Sub dataGrid1_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
     Me.dataGrid1.Select()

End Sub