Home Forums WinForms controls Xceed Grid for WinForms creating toggle effect

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16053 |

    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)

    Xceed Support
    Member
    Post count: 5658

    There is 2 parameters you need to take into consideration.

    -Is the GridControl in SingleClickEdit mode? If not, the user you need to click once to select the cell and click a second time to change the value.

    -How do you handle the Editor of the cell? An interesting thing would be subscribe to the value changed event on the Editor of the cell (through the ActivatingControl event on the CellEditorManager). After, when the value of the Cell Editor is changed, you call a EndEdit() on the cell to commit immediately the value after the user’s click.

    Imported from legacy forums. Posted by CharlesB (had 923 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.