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
530
Handle checkbox change immediately
posted

I have a data grid that is bound to a hierarchical object.  Both the top level and the child level objects have checkboxes.  I want them to behave like a typical tree view, wherein the parent checkbox is a tri-state and if the user clears or sets it the child objects are checked/uncheked appropriately.

I curently have the UpdateMode set to OnCellChange but I need the change to be propogated to my child objects immediately after the checkbox is clicked rather than after the user moves off of the cell.  Is there another property or maybe an event that fires when the checkbox is changed so that I can manually call update?

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    What you can do is handle the grid's CellChange event and call grid.ActiveRow.Update. This will commit all changed to the current row to the grid's DataSource. It's probably a good idea to only do this for CheckBox cells, though, as it could cause an error for other types because CellChange fires for every keystroke.

    For example, if you have a date field, the user could type a single character, which is not a valid date, and you would not want to update in that case. It's safe for a CheckBox cell, though, since the user cannot enter a partial value - it's either checked or unchecked.

Children