Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
540
Cell not refreshed immediately when value changed
posted

Hi IG,

I have this code:

private void _grid_KeyDown(object sender, KeyEventArgs e)
{
        //delete key = clear the current cell
        if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
        {
                if (0 == (_grid.CurrentState & UltraGridState.InEdit))
                    if (_grid.ActiveCell != null)
                            if (_grid.ActiveCell.Value is CellClass)
                                (_grid.ActiveCell.Value as CellClass).Clear();
        }
}

The problem is, the cell is not refreshed/repainted until you move the mouse over, or scroll/resize the column, etc.
Cell is displayed as string, and CellClass has ToString() via IConvertible.

I tried adding BeginInvoke() around -> no success.
I tried _grid.ActiveCell.Refresh() -> no success.
I tried _grid.Invalidate(_grid.ActiveCell.GetUIElement().Rect) -> no success.
I tried reassign the same value to the ActiveCell  -> no success.

I debugged, and the ActiveCell.Text immediately changes to "" after calling Clear().

What could be the problem? Thanks.