RE: NullReferenceException when delete last row in a datagrid

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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)
>
>
>
.



Relevant Pages

  • Re: Israelis firing live rounds at West Bank protesters
    ... "don't fight an oppressor and you won't have any trouble". ... reason to do what they do. ... Northern Ireland; I think the Belfast-born Irish president Mary ... is Ireland, England is England, therefore there is no logical reason ...
    (uk.politics.misc)
  • Re: Israelis firing live rounds at West Bank protesters
    ... people don't throw stones, shoot, fight and die for the fun. ... but the reason for beginning it in the ... As to Ireland, it is simple from the republican point of view, Ireland ... is Ireland, England is England, therefore there is no logical reason (as ...
    (uk.politics.misc)
  • Re: Its Over
    ... the IRA/UK struggle seemed every bit as solutionless and ... but iirc the main goal of the IRA was to unify NI with the rest of Ireland, despite the fact that a majority of NI residents were protestants who preferred union with england. ... not reasonable, IMO, even though of course the only reason that NI had a protestant majority as because of historical british invasions/usurpations in ireland. ... all the markets were full of fish product. ...
    (rec.sport.football.college)
  • Re: cleansed again
    ... >>then blame it on ireland and tennessee ... > There's a reason why novice writers often receive the admonishment to ... Learn some basics of just letting it go. ...
    (rec.arts.poems)