RE: NullReferenceException when delete last row in a datagrid
- From: Brian Delahunty <BrianDelahunty@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 15 Aug 2005 03:43:03 -0700
Can you post your code please.
--
Brian Delahunty
Ireland
http://briandela.com/blog
INDA SouthEast - http://southeast.developers.ie/ - The .NET usergroup I
started in the southeast of Ireland.
"Ryan Liu" wrote:
> 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)
>
>
>
.
- Follow-Ups:
- References:
- NullReferenceException when delete last row in a datagrid
- From: Ryan Liu
- NullReferenceException when delete last row in a datagrid
- Prev by Date: Re: excuse me if this is a real noddy question ...
- Next by Date: RE: Single instance of an object between different processes?
- Previous by thread: NullReferenceException when delete last row in a datagrid
- Next by thread: Re: NullReferenceException when delete last row in a datagrid
- Index(es):
Relevant Pages
|