Sorry accidently posted the prevoius post before it was finished.
Well, my question is... Wich is the right way to remove all rows in a GridControl? I am using this method :
if (m_grid.Model.RowCount != 0)
I often get a NullReferenceExeption doing it this way. see below.
catched at Syncfusion.Windows.Forms.Grid.GridCurrentCell.Validate() in :line 0
catched at Syncfusion.Windows.Forms.Grid.GridCurrentCell.ConfirmChanges(Boolean closeDropDown) in :line 0
catched at Syncfusion.Windows.Forms.Grid.GridModelRowOperations.RaiseRemoving(GridRangeRemovingEventArgs e) in :line 0
An unhandled exception of type ''System.NullReferenceException'' occurred in syncfusion.grid.dll
Is there a right way of doing it? or can it be something else in my code that causes the exeption?
ADAdministrator Syncfusion Team September 24, 2004 05:49 AM
are you handling any validating events?
Something must be happening along these lines in CurrentCell.Validate:
// possibly shows a dialog box (but user can also set CurrentCell.ErrorMessage)
IsValid = Grid.RaiseCurrentCellValidating() && cellRenderer.RaiseValidate();
By the time CurrentCellValidating the renderer seems to be gone because the current cell was deactivated.
We''ll add a null reference check to avoid this being a problem in our code for future builds.
But, what you can do for now is simply call CurrentCell.Deactivate() before you call RemoveRange. That way there is no current cell to start with and above Validate code will not get hit at all during the RemoveRange operation.
PEPeter EriksonSeptember 24, 2004 06:42 AM
Thanx for the info on this and the fast response.
You are probarbly right regarding the Cell validaton. And that that is the source of the problem.
I´ll se if the CurrentCell.Deactivate solution fixes it.