We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ArgumentOutOfRangeException or StackOverflowException occured when row updated from RowChanged

Thread ID:





58739 Mar 27,2007 01:56 PM UTC Mar 28,2007 06:18 AM UTC WinForms 2
Tags: GridControl
Asked On March 27, 2007 01:56 PM UTC

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
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;

private void Form1_Load(object sender, System.EventArgs e)
myTable = new DataTable("DN_ACCOUNT");
myTable.Columns.Add("ID", typeof(Int32));
myTable.Columns.Add("Text", typeof(String));

myTable.RowChanged += new DataRowChangeEventHandler(myTable_RowChanged);

gridDataBoundGrid1.DataSource = myTable;

private void myTable_RowChanged(object sender, DataRowChangeEventArgs e)
e.Row["ID"] = 1;

Rajagopal [Syncfusion]
Replied On March 27, 2007 08:41 PM UTC


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;

// or //

private void myTable_RowChanged(object sender, DataRowChangeEventArgs e)
if(e.Action == DataRowAction.Add)
e.Row["ID"] = 1;

Let us know if you need any further assistance.

Replied On March 28, 2007 06:18 AM UTC

Hello, thanks for reply. It was helpful to me.
But I found the real reason of exception.
If I do something like this:

private void myTable_RowChanged(object sender, DataRowChangeEventArgs e)
if(e.Action == DataRowAction.Add)
//e.Row["ID"] = 1;

I still get ArgumentOutOfRangeException. Why I can't use this functions in RowChanged handler?


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon