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.
Hello I get ArgumentOutOfRangeException or StackOverflowException after changing some values from RowChanged handler.
Here is exceptions:
A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at Syncfusion.Windows.Forms.Grid.GridScroll.RecalcHiddenRowState(Int32 start, Int32 end) at Syncfusion.Windows.Forms.Grid.GridControlBase.ModelRowsRangeRemoved(Object sender, GridRangeRemovedEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.OnRowsRemoved(GridRangeRemovedEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModel.RaiseRowsRemoved(GridRangeRemovedEventArgs e) at Syncfusion.Windows.Forms.Grid.GridModelRowOperations.OnRangeRemoved(GridRangeRemovedEventArgs e) catched at Syncfusion.Windows.Forms.Grid.GridModelRowOperations.OnRangeRemoved(GridRangeRemovedEventArgs e) in :line 0 ---------------or-------------- An unhandled exception of type 'System.StackOverflowException' occurred in syncfusion.grid.windows.dll
Fatal stack overflow error.
I simulated my issue in code. Try to add new row by editing Text column. ------------------------------------------------- DataTable myTable;
RARajagopal Syncfusion Team March 27, 2007 08:41 PM UTC
Hi,
The RowChanged event of the DataTable gets trigerred whenever any changes to the datarow is made. So, when you try to set a value to the underlying datasource in this event, causes the event to fire continously for various actions leading to throw exception. To resolve this, you can check for e.Action to be as DataRowAction.Add in the RowChanged event or handle the CurrentCellAcceptedChanges event of the grid to do set the value. Below are the code snippets.
private void gridDataBoundGrid1_CurrentCellAcceptedChanges(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell; int textColIndex = this.gridDataBoundGrid1.Binder.NameToColIndex("Text"); if(cc.RowIndex > 0 && cc.ColIndex == textColIndex && this.gridDataBoundGrid1.Binder.IsAddNew) { CurrencyManager cm = (CurrencyManager)this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource]; DataRow dr = ((DataRowView)cm.Current).Row; dr["ID"] = 1; } }