We have business logic that should conditionally allow a user to click to (or otherwise move to) a row and begin editing. The closest event I can find is the beforerowactivate event, but this is not an event that can be cancelled. Is there a way to do this or perhaps the most recent version of the grid has an event for this? Thanks for any help!
Hi,
This is really not feasible for the grid to do. The grid's active row stays in synch with the Current position of the CurrencyManager. There is no way to prevent the currency manager from activating a particular row, so there's no way for the grid to do so, either.
You could use the Activation or CellActivation to disable the row. HOWTO:How can I make a grid or a column, row, or cell in the UltraWinGrid disabled or read-only?
I also have this issue. I agree there is no way to prevent the currentManager from activating a particular row, but in this case it's the user that is activating the row not the CurrencyManager. There should be a way to cancel the user event of the row being activated. One thing I've thought of but haven't tried is to handle the BeforeSelectChange event(which is also called during activation) and if you want to cancel the row activation simple re-active the old row. Would this work?
Okay, but just to be clear, this does not actually prevent the activation of the row, it just activates some other row after the row has already been activated.
If you do not want a particular row in the grid to be activated, you should use the Activation property on the row to disable it.
My scenario is the following:
I am using the Grid to select rows, and then displaying their contents on a details panel. The user can then make changes to the data at which point it switches into an Edit state. In this state the user can then try to select a different row. If they do this I display a message that they are currently editing the active row and that they can cancel the changes or continue editing the current row. If they cancel the new row is selected and if they continue editing the old row remains selected. Of course I could just disable the entire grid in this scenario, but they still need to be able to sort, group etc.
So what is the best solution for this scenario? Is it to set the Activation property for every row to false if my screen switches to edit mode? If so can I still recieve a notification that a new row is trying to be activated to prompt a dialog? If they choose 'Cancel' in this dialog can the selected row be re-enabled and selected within the notification?
Even if this is possible it does seem a little easier to simply have a Cancel property in the BeforeRowActivate event handler. This would signify that you want to cancel(but still handle) the user event of clicking on a new row(just as BeforeSelectChange currently does). I got the BeforeSelectChange solution I mentioned earlier to work. It also re-activates the previously active row, but this seems to do the trick.
peljam said:So what is the best solution for this scenario? Is it to set the Activation property for every row to false if my screen switches to edit mode? If so can I still recieve a notification that a new row is trying to be activated to prompt a dialog? If they choose 'Cancel' in this dialog can the selected row be re-enabled and selected within the notification?
This seems like it would be doable. You would have to trap the MouseUp or MouseDown event and get the row the user clicked on to show your prompt and then if they decided to cancel, you could re-enable the rows and make it the active row and even activate the cell they clicked and put it into edit mode.
peljam said:Even if this is possible it does seem a little easier to simply have a Cancel property in the BeforeRowActivate event handler. This would signify that you want to cancel(but still handle) the user event of clicking on a new row(just as BeforeSelectChange currently does). I got the BeforeSelectChange solution I mentioned earlier to work. It also re-activates the previously active row, but this seems to do the trick.
I agree this would be easier, but it is currently not supported. You can submit a feature request to Infragstics: Request a Feature or Component
You can trap the BeforeRowDeactivate event and cancel it leaving the same active row. This will happen prior to BeforeRowActivate on the row that was attempted to be activated.
Thanks ksedlazek
I was able to solve my problem using your suggestion. It avoided keeping track of previously activated rows.
ksedlazek,
I had this requirement as well, and solved it the same way.
Thanks from me too!