CB
Clay Burch
Syncfusion Team
September 3, 2002 05:37 AM UTC
> I have a data bound grid with a column that uses a custom cell renderer derived from GridStaticCellRenderer. I use a custom control within the renderer to allow editing of the data in the column, which is of type int.
>
> How should I go about getting the value from my custom control into the grid model and/or underlying dataset?
>
> I've tried updating the underlying dataset directly from the renderer's OnDeactivated() method, but then the grid still shows the old value, not the new value that is correctly stored in the dataset.
>
> Is there some object (model?) between the renderer and the dataset that I should set instead, or is there a way to force the renderer to re-render the cell after updating the dataset directly?
>
> TIA.
Saving changed values in normally done in the renderer's OnSaveChanges virtual method. Here is the code that is in the GridCellRendererBase baseclass.
protected internal virtual bool OnSaveChanges()
{
if (CurrentCell.IsModified)
{
Grid.Model[currentRowIndex, currentColIndex].FormattedText = this.ControlText;
return true;
}
return false;
}
So, in your renderer code, if you set ControlText and CurrentCell.IsModified to be true when the cell value is changed, this may be all you need to do to tie into the grid's normal updating architecture.
If that does not work, you can override OnSaveChanges, and try other code there to save the changed value.