Hi there,
I got a NullReferenceEx ception 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.NullRefe renceException: 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. DeleteDataGridR ows(Int32 deletedRows)
at System.Windows. Forms.DataGrid. DeleteRows(Data GridRow[] localGridRows)
at System.Windows. Forms.DataGrid. ProcessGridKey( KeyEventArgs ke)
at System.Windows. Forms.DataGrid. ProcessDialogKe y(Keys keyData)
at System.Windows. Forms.Control.P rocessDialogKey (Keys keyData)
at System.Windows. Forms.TextBoxBa se.ProcessDialo gKey(Keys keyData)
at System.Windows. Forms.Control.P reProcessMessag e(Message& msg)
at
System.Windows. Forms.ThreadCon text.System.Win dows.Forms.Unsa feNativeMethods +IMsoComponent. FPreTranslateMe ssage(MSG&
msg)
at
System.Windows. Forms.Component Manager.System. Windows.Forms.U nsafeNativeMeth ods+IMsoCompone ntManager.FPush MessageLoop(Int 32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows. Forms.ThreadCon text.RunMessage LoopInner(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
I got a NullReferenceEx ception 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.NullRefe renceException: 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. DeleteDataGridR ows(Int32 deletedRows)
at System.Windows. Forms.DataGrid. DeleteRows(Data GridRow[] localGridRows)
at System.Windows. Forms.DataGrid. ProcessGridKey( KeyEventArgs ke)
at System.Windows. Forms.DataGrid. ProcessDialogKe y(Keys keyData)
at System.Windows. Forms.Control.P rocessDialogKey (Keys keyData)
at System.Windows. Forms.TextBoxBa se.ProcessDialo gKey(Keys keyData)
at System.Windows. Forms.Control.P reProcessMessag e(Message& msg)
at
System.Windows. Forms.ThreadCon text.System.Win dows.Forms.Unsa feNativeMethods +IMsoComponent. FPreTranslateMe ssage(MSG&
msg)
at
System.Windows. Forms.Component Manager.System. Windows.Forms.U nsafeNativeMeth ods+IMsoCompone ntManager.FPush MessageLoop(Int 32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows. Forms.ThreadCon text.RunMessage LoopInner(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.ThreadCon text.RunMessage Loop(Int32 reason,
ApplicationCont ext context)
at System.Windows. Forms.Applicati on.Run(Form mainForm)
Comment