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
810
UpdateMode.OnRowChangeOrLostFocus does not work if cell changed by context menu
posted

I set the grid's UpdateMode to OnRowChangeOrLostFocus and it works fine unless I have a context menu on the row that updates a cell value. The row just stays in edit mode. In fact I can edit several rows and they all stay in edit mode unless or until I call row.Update(). The context menu just brings up an edit or copy choice that let's me edit the cell in a special xml text dialog so I have a larger edit area. When I close the dialog, I update the cell's value if anything changed in my edit dialog. Works if I call row.Update() after changing the cell value but that commits the edit for the row without allowing ESC to cancel the edit. Why doesn't UpdateMode=OnRowChangeOrLostFocuswork if I switch to another row? I have debugged that property is still set when I return form the dialog and changed the cell value.

- Dave

  • 469350
    Verified Answer
    Offline posted

    Hi Dave,

    I'm not sure I follow you. Regardless of the setting of UpdateMode, changing the active row in the grid has to update the grid's underlying data source. The BindingManager will do this automatically, assuming SyncWithCurrencyManager on the grid is true. So the grid could not prevent those updates from taking place even if it wanted to.

    So if you are somehow updating the active row and moving away from that row and the row changes are not committed to the data source, then something very strange is going on.

    Perhaps this is a result of the fact that you are changing the cell values in code, rather than through the UI of the grid. I would think it would still work, but it might depend on exactly how you are updating the data. Are you setting the Value on the grid cell? Or updating the data source directly? 

    I think what you might need to do is use the SetCellValue on the row so that the grid simulates a user update to the row, but I have not tried it.