thomas10001
Regular
Hi
I have a strange bug that I get.
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 System.Windows.Forms.CurrencyManager.CancelCurrentEdit()
at System.Windows.Forms.DataGrid.HandleEndCurrentEdit()
at System.Windows.Forms.DataGrid.OnLeave_Grid()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
I cannot debug it! It is outside my control I believe.
I have seen on a site that this is a possible bug from microsoft.
But I do not know how to fix it.
I cannot provide all code as a sample because it is too much to post here.
But I have a datagrid that is feed by an ArrayList which is embedded into an object.
The bug appear somewhere I cannot debug.
If I run my code to make a new entry (New Button)
and directly after run my Save code and close the whole window and then
reopen the window I will not get the error.
But if I directly after the New Button enter a value into my field and the save, then I will get the error above.
A small part from my code from my New button.
I do not know if this is to any help or if it is here there is a cause to the bug.
Anyone have an idea how to find the bug or fix it?
public void newClicked(UserControlBase callingControl,int callingControlRowClicked,int newRowClicked)
{
// If we have datamappings we must make a new row in arraylist of datamapping
DataMapping dm = this.getCurrentUserControl().getDataMapping();
string showTableName = this.getCurrentUserControl().getShowTable();
if(dm.Count > 0) // are we using datamappings?
{
((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataSource = null;
cs = (CurrencyManager)this.BindingContext[dm.arrayList];
cs.EndCurrentEdit();
cs.List.Add(new DataList()); // could do dm.AddDataList() instead. its the same
cs.Refresh(); // seem to be not needed!
((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataMember = "";
((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataSource = this.getCurrentUserControl().getDataMapping().arrayList;
}
I have a strange bug that I get.
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 System.Windows.Forms.CurrencyManager.CancelCurrentEdit()
at System.Windows.Forms.DataGrid.HandleEndCurrentEdit()
at System.Windows.Forms.DataGrid.OnLeave_Grid()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
I cannot debug it! It is outside my control I believe.
I have seen on a site that this is a possible bug from microsoft.
But I do not know how to fix it.
I cannot provide all code as a sample because it is too much to post here.
But I have a datagrid that is feed by an ArrayList which is embedded into an object.
The bug appear somewhere I cannot debug.
If I run my code to make a new entry (New Button)
and directly after run my Save code and close the whole window and then
reopen the window I will not get the error.
But if I directly after the New Button enter a value into my field and the save, then I will get the error above.
A small part from my code from my New button.
I do not know if this is to any help or if it is here there is a cause to the bug.
Anyone have an idea how to find the bug or fix it?
public void newClicked(UserControlBase callingControl,int callingControlRowClicked,int newRowClicked)
{
// If we have datamappings we must make a new row in arraylist of datamapping
DataMapping dm = this.getCurrentUserControl().getDataMapping();
string showTableName = this.getCurrentUserControl().getShowTable();
if(dm.Count > 0) // are we using datamappings?
{
((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataSource = null;
cs = (CurrencyManager)this.BindingContext[dm.arrayList];
cs.EndCurrentEdit();
cs.List.Add(new DataList()); // could do dm.AddDataList() instead. its the same
cs.Refresh(); // seem to be not needed!
((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataMember = "";
((UserControlWinGrid)this.getCurrentUserControl()).getDataGrid().DataSource = this.getCurrentUserControl().getDataMapping().arrayList;
}