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
260
Value changed on a Checkbox cell
posted

Hi,

I am using UltraWinGrid which contains a boolean column. So each cells is displayed correctly as a checkbox.

The grid data is handled by a binding object.

When the user clicks on a cell, the checkbox is checked or unchecked as expected. But my data object is notified of a CellValueChanged only when the user clicks outside of the grid.

There is any way to handles the checkbox clicks or state changed to force a data update ?

I tried to handle the CellChange event and, if it is a checkbox cell, force an exit of the edit mode. But it doesn't work as expected, it blocks the native checkbox behavior...

Best regards,

Jean-Charles Durand

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    You could do this:


            private void ultraGrid1_CellChange(object sender, CellEventArgs e)
            {
                if (e.Cell.Column.DataType == typeof(bool))
                {
                    e.Cell.Row.Update();
                }
            }      

    But this may not be ideal, because it will commit any changes in the entire row.

    Another option would be to just get the new value of the cell inside the CellChange event and use it for whatever you need, without updating the data source.But to do that, you have to use the Text property of the cell.


            private void ultraGrid1_CellChange(object sender, CellEventArgs e)
            {
                if (e.Cell.Column.DataType == typeof(bool))
                {
                    bool newValue = bool.Parse(e.Cell.Text);
                    Debug.WriteLine(newValue);
                }
            }       

Children