Hi,
I am getting the error message as "Cannot access a disposed object.Object name: 'Infragistics.Win.UltraWinGrid.UltraGridCell'.".
the line of code generating such error is
this.CustomerMarkUpGrid.Rows[i].Cells["IsDefault"].Value = true.
Interesting issue is that when ever i try to assign false instead of true there is no any error message. error occurs only when i try to assign true.
I tried to catch this error in CellDataError event of grid, but unfortunately CellDataError event of grid is not fired.
What event is this line of code in?
What is the value of "i" when the error occurs?
You won't get a CellDataError or Error event for something like this because the error has nothing to do with the data. The error indicates that a cell inside a row has been disposed. The only way I can think of that this could possibly happen is if the grid has somehow gotten out of synch with the UI Thread. My best guess is that you are using multiple threads in your application and there's a marshalling problem somewhere.
The event of this line of code is on Cell_Change, the code goes as below
private void CustomerMarkUpGrid_CellChange(object sender, CellEventArgs e) { if (this.CustomerMarkUpGrid.ActiveCell.Column.Key == "IsDefault" && this.CustomerMarkUpGrid.Rows.Count > 0) { int currentIndex = CustomerMarkUpGrid.ActiveCell.Row.Index; bool toSet = Convert.ToBoolean(this.CustomerMarkUpGrid.ActiveCell.Row.Cells["IsDefault"].Text); for (int i = 0; i < this.CustomerMarkUpGrid.Rows.Count; i++) { if (currentIndex == i) { this.CustomerMarkUpGrid.Rows[i].Cells["IsDefault"].Value = toSet;
I still could not figure out why it is giving such error..
Well, I have two guesses.
One is what I said previously: that your application is using multiple threads.
The second is that by setting the Value on a cell inside the CellChange event, you are causing CellChange to fire recursively. You might want to try using the EventManager to disable the CellChange event while you are in it.
This code does not make a whole lot of sense to me, though. What exactly are you trying to do here.
It appears that this code is trapping for changes to a cell in the IsDefault column and any time the user types into this cell, you are changing the value on the cell to something other than what they typed.
I don't see how this code could work or why you are looping through all of the rows in order to find the cell you are already on.
I just noticed it occurring with my code as well, but I is not due to multiple theads.
In my case it appears to be due to data changes that are triggered that cause the row from the datasource to be excluded from the data which is displayed on the grid. This seems to cause the entire row to be disposed while it is trying to update. My update mode is set to on cellchange or lostfocus
Changing my updatemode to RowChange or OnUpdate does not seem to help. Note that many of the cells in my grid are set to select the row on click. I have tried selecting another normal cell after updating the ones that causes the row to be lost, but it doesn't seem to help as the column is still updated in the datatable.
I have not yet found a good workaround, other than to adjust my filter to forcibly include the row being modified and get everything I need from inside the Before cell update event, because it is not available most of the time in the after cell update event. The problem with this is that it causes all of the data to be reloaded/reinitialized and I have to then readjust the grid again (read slow).
Can you post a small sample project that duplicates the exception?
There's not much to go on here. How exactly are you updating the row in such a way that it no longer appears in the grid? What event is triggering this operation?