neverrealm
asked on
C# Problem with DataGridView. Throwing an exception after the addition of an event handler.
I have a C# project, in which, although not running properly, actually runs. I have a DataGridView in this application.
Once I add a handler to the CellValueChanged event of the DataGridView, it throws an IndexOutOfBounds Exception. Removing the Event Handler, causes the exception to disappear.
The definition for the Event Handler is as follows:
private void rankingsDataGridView_CellV alueChange d(object sender, DataGridViewCellEventArgs e)
{
UpdateTopPercentage(rankin gsDataGrid View[e.Col umnIndex, e.RowIndex].Value.ToString (), false);
}
It throws the IndexOutOfBounds on Initialize Component on the Form Load on the following line:
resources.ApplyResources(t his.Rank, "Rank");
where this.Rank is a DataGridViewTextBoxCell which has been added to the DataGridView. As said before, merely eliminating the Event Handler rectifies the exception.
What could cause this error?
Once I add a handler to the CellValueChanged event of the DataGridView, it throws an IndexOutOfBounds Exception. Removing the Event Handler, causes the exception to disappear.
The definition for the Event Handler is as follows:
private void rankingsDataGridView_CellV
{
UpdateTopPercentage(rankin
}
It throws the IndexOutOfBounds on Initialize Component on the Form Load on the following line:
resources.ApplyResources(t
where this.Rank is a DataGridViewTextBoxCell which has been added to the DataGridView. As said before, merely eliminating the Event Handler rectifies the exception.
What could cause this error?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I ended up moving the sorting out of the cell events. There's also a track bar that keeps track and edits the cell, so I moved the sorting over to the value changed event of the track bar and that fixes an issue with recurrent CellEdit calls that I was looking to fix with the CellValueChanged event handler.
private void rankingsDataGridView_CellV
{
If(loaded)
UpdateTopPercentage(rankin
}
loaded is false initially and is set to true at the ened of the form load.