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
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); } }
Thanks guys !
I will try all of these solutions.
@Mike: the second one might be the best, but in my case, I how to force an update of the data binding... So maybe I will have to update all the row.
I will keep you aware of what I choose.
Best regards.
Hello,
Thank you for your feedback.
Please do not hesitate to contact with us if you have any further questions.
Hi guys,
Finally, I choose the second solution proposed by mike.
It works fine !
Thanks for the support.