I wonder if someone can help me with something that's had me banging my head against the wall for a good while.
In my grid, if the user modifies a row and tabs away, I may need to merge that row with another row. So in grid_AfterRowUpdate event, I delete the selected row, and want to select the new row it was merged with.
I can set this fine within this event. But because AfterRowUpdate fires before the tab away from the cell action completes, the grid always subsequently sets my selection onto the row after the original one I deleted. I can't figure out a way to Cancel this behaviour and persist my new selection.
Any assistance greatly appreciated.
Thanks.
Hello Campbell,
I have been investigating into the behavior you are looking to achieve, and I would like you to take a look at the sample project I am attaching. In the sample project, to simulate your “merging” I have multiple rows in the grid with the same ID, and when one is updated, the other one will be selected.
This was a bit tricky to implement, but rather than using the AfterRowUpdate event, I would recommend using BeforeRowUpdate for this, as this event is cancellable and can prevent the default tab activity if you cancel it. With that said, you can unhook the BeforeRowUpdate event, call the Update() method on the Row to force-update it, and then re-hook the event after moving your selection.
This is demonstrated in the sample project attached. I hope it helps you.
Please let me know if you have any other questions or concerns on this matter.
UltraGridSelectionCase.zip
Worked like a charm. Thank you very much. :)