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
Works for me. Thanks!
Hi Dave,
No, this is not a bug. I assumed you were already setting the row as active when you showed your context menu which is why I was so confused.
OnRowChangeOrLostFocus means that the focus moves away from the row that was edited. If that row was not the ActiveRow, then changing rows or losing focus from the grid will not do anything. It's designed to handle user updating. If you are updating the data in code behind the grid's back (so to speak), then the grid should not automatically update the data when it loses focus - that would not make sense.
Using SetCellValue also allowed multiple rows to stay in edit mode with none updating when changing rows. Setting the row active when I clicked the cell with the mouse did the trick. Not sure if you want to consider this a bug but moot to me at this point. Thanks, Dave
P.S. The row I change stays in edit mode with the little pencil icon. In fact I can have several rows in edit mode and none of them leave edit mode till I hit ^U which in my app is wired to grid.Update().
Hi Mike,
I do set the row in code depending on the DialogResult from my dialog run from the RMB context menu on the cell. Not sure if it becomes the active row by my clicking the RMB for a context menu or not but I can perhaps set it active and see if that makes a difference.
I do not update any data directly and use cell.Value = "some xml string" and do not use the SetCellValue method. I do not set SyncWithCurrencyManager at all so use the default behaviour.
I'll try these techniques as I don't want to call Update and commit before the user decides to leave the row.
Thanks, Dave