We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I delete rows from datagrid control

hi all, I want to delete rows from datagrid control on clicking a button. So I gave datagrid.SetDataBinding( null, null ); It is deleting all the rows, but it gives the following exception. Could any one give me a solution for this ? System.IndexOutOfRangeException: Index was outside the bounds of the array. at System.Windows.Forms.DataGrid.GetCellBounds(Int32 row, Int32 col) at System.Windows.Forms.DataGrid.GetCurrentCellBounds() at testdatagrid.OnPaint_datagrid(Object sender, PaintEventArgs e) at System.Windows.Forms.Control.OnPaint(PaintEventArgs e) at System.Windows.Forms.DataGrid.OnPaint(PaintEventArgs pe) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) regards, lat.

1 Reply

AD Administrator Syncfusion Team September 25, 2002 05:26 AM UTC

Before you reset the datasource, try setting the currentcell to 0,0. this.dataGrid1.CurrentCell = new DataGridCell(0, 0);

Loader.
Live Chat Icon For mobile
Up arrow icon