G
Guest
Hi!
In my windowsformapplication I have a DataGrid where the rowheader is not
visible, and readOnly = true. The grid is bound to a DataView where
AllowEdit, AllowNew and AllowDelete is set to false.
To be able to select an entire row on mouseclick I've created a MouseUp event.
Private void DataGrid1_MouseUp (object sender,
System.Windows.Forms.MouseEventArgs e)
{
Point pt = new Point (e.X, e.Y);
this.DataGrid1.Select(this.DataGrid1.HitTest1(pt).Row);
}
My problem occures when I click outside or under my last row. I recieve
following message: "Index was outside the bounds of the array" with choice to
continue or quit.
How do I prevent this to happen?
In my windowsformapplication I have a DataGrid where the rowheader is not
visible, and readOnly = true. The grid is bound to a DataView where
AllowEdit, AllowNew and AllowDelete is set to false.
To be able to select an entire row on mouseclick I've created a MouseUp event.
Private void DataGrid1_MouseUp (object sender,
System.Windows.Forms.MouseEventArgs e)
{
Point pt = new Point (e.X, e.Y);
this.DataGrid1.Select(this.DataGrid1.HitTest1(pt).Row);
}
My problem occures when I click outside or under my last row. I recieve
following message: "Index was outside the bounds of the array" with choice to
continue or quit.
How do I prevent this to happen?