The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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)
m_grid.Rows.RemoveRange(1, m_grid.Model.RowCount);
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?
Thanx.
/Peter
ADAdministrator Syncfusion Team September 24, 2004 09:49 AM UTC
Hi Peter,
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();
if (IsValid)
{
cellRenderer.RaiseValidated();
Grid.RaiseCurrentCellValidated();
}
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.
Stefan
PEPeter EriksonSeptember 24, 2004 10:42 AM UTC
Hi Stefan,
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.
Thanx!