I've searched for hours with no luck. I've got a button that changes the value for a cell in every row of a band in the grid. In order to get the values "stick" I have to focus the grid using Focus() or Select(). The problem I have is it redraws the grid and I lose all expansions and other changes. If I upate the values without focusing the grid everything looks good until you click on the grid, then all the values are gone (I'm guessing this is because the values don't get written back to the dataset?).
Is there an event I could trigger to verify that it is infact rebinding?
The only event I have code on for the grid is CellChanage.
As with most of my code, it's kinda cumbersome, but here is the code in the form button that sets the value:
oGrid.Focus();
{
oGrid.PerformAction(Infragistics.Win.UltraWinGrid.
UltraGridAction.EnterEditMode);
oRow.Cells[printField].Value =
true;
UltraGridAction.ExitEditMode);
}
The grid should never be rebinding the data source simply by getting focus, that would only generally happen when the data source itself sends a Reset notification. Are you using enter/exiteditmode events to update the values in all of the cells? Is there any chance that you can post a small sample that I could take a look at to see what you're doing? Another possibility is that you're changing the cell values in InitializeRow, overwriting the values in unbound columns and possible changing the Expanded state.
-Matt
I've tried value = and setvalue, and I'm using enter/exit edit mode. I've done it before and it worked, I think it's because I bind to a table for the values, but then add unbound check boxes to the grid for selection. The data from the bound object never gets changed or updated, only the checkboxes, expansions, and row activation get changed. Could the Focus() be calling the update and rebinding to the datasource?
How are you updating the cells? Are you just looping through all the rows and cells and updating them? What it sounds like is that the data source is sending a Reset notification to the grid, causing it to regenerate all of its rows, though I can't really say why this wouldn't happen until the grid has received focus.
As a side note, it will certainly be more performant to wrap your updates in a BeginUpdate/EndUpdate on the grid.