I want to create a toggling effect for a column (type of string) which shows only two string values (e.g. valueA, valueB). When I click on the cell for that columan, it changes its value from valueA to valueB or from valueB to valueA. I tried implementing that by writing a Click event handler:
private void cell_Click(object sender, EventArgs e)
{
Cell cell = (Cell)sender;
if (cell.Value == valueA)
{
cell.Value = valueB;
}
else
{
cell.Value = valueA;
}
}
It seems working for me except for this case: When I first click on the cell, the cell value toggles. Without leaving the focus on the cell, I click on the cell again. I expected the field toggling the value, but it did not. (If I placed the focus away from the cell, and then click the cell again, it successfully toggles its value.)
I tried debugging by tracing the code, the cell value did change (toggle), but the effect didn’t show up on the grid. This is bad, as the cell value is different from what it shows on the grid.
How can I make the cell on the grid updates its value?
Thanks a lot.
Imported from legacy forums. Posted by Sop (had 635 views)