R
Ryan Liu
Hi there,
I got a NullReferenceException when delete last row in a datagrid.
I had hard time to solve since it does not occur in my own code.
I put a datagrid in my inherited user control, then put this control on a
form.
I use DataAdaptor to fill the data table and update database.
I have no problem to delete rows in datagrid, unless it is last row.
If I do delete the last row, use Delete key on my keyboard, it throws
following exception.
Is this a known bug? Or can someone point out the clue I can look at? Since
the delet is not handled by myself, I really don't know how to solve it.
Thanks a lot!
Ryan
System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.DataGrid.ResetSelection()
at System.Windows.Forms.DataGrid.ResetUIState()
at System.Windows.Forms.DataGrid.SetDataGridRows(DataGridRow[] newRows,
Int32 newRowsLength)
at System.Windows.Forms.DataGrid.DeleteDataGridRows(Int32 deletedRows)
at System.Windows.Forms.DataGrid.DeleteRows(DataGridRow[] localGridRows)
at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEventArgs ke)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at
System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG&
msg)
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
I got a NullReferenceException when delete last row in a datagrid.
I had hard time to solve since it does not occur in my own code.
I put a datagrid in my inherited user control, then put this control on a
form.
I use DataAdaptor to fill the data table and update database.
I have no problem to delete rows in datagrid, unless it is last row.
If I do delete the last row, use Delete key on my keyboard, it throws
following exception.
Is this a known bug? Or can someone point out the clue I can look at? Since
the delet is not handled by myself, I really don't know how to solve it.
Thanks a lot!
Ryan
System.NullReferenceException: Object reference not set to an instance of an
object.
at System.Windows.Forms.DataGrid.ResetSelection()
at System.Windows.Forms.DataGrid.ResetUIState()
at System.Windows.Forms.DataGrid.SetDataGridRows(DataGridRow[] newRows,
Int32 newRowsLength)
at System.Windows.Forms.DataGrid.DeleteDataGridRows(Int32 deletedRows)
at System.Windows.Forms.DataGrid.DeleteRows(DataGridRow[] localGridRows)
at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEventArgs ke)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at
System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG&
msg)
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)