Hi,
When using the ultrawingrid (version 11.2.20112.1010) and a bindinglist as a datasource I am searching for a way to trap the event when an item was deleted (or added) from (to) the bindingsource.Or to be more general: an event like the ListChanged event (on a BindingList) notifying me of any changes in the datasource of the grid.
I noticed there is a BeforeRowsDeleted and AfterRowsDeleted event but these only fire when using the "del" key (allowdelete=true and selecttyperow <> none) on a selected row.In my case the add or remove happens on the bindinglist that is used as a datasource for the grid and thus the events mentioned above do not fire.The only way to trap these events, according to my current knowledge, is to use the ListChanged event on a BindingList.
Why would I be needing these events?1. When an item is removed from the list I want to select the next item in the list.2. When the last item is removed from the list I want the AfterRowActivate or SelectChange event to fire with "nothing" as a value. In order for me to know that "nothing" is active/selected and I canclear some other fields in my application (that contain additional data of the current selected and/or active item). Currently these events are not fired...
Both of the above scenarios can occur when the grid is filtered.I would prefer to use events of the grid instead of events of the BindingList to fulfill my needs.
Any help would be greatly appreciated.
Thank you.
Mike, Boris,
Thanks for your replies. When I replied I already tried it out (of course :-)). No further assistance required. Thanks for the follow-up!
Hello Michael,
I am glad to hear that this would suit your needs also. Please when you try it, feel free to let me know if something comes up, I will be glad to assist you further.
The events you are looking for are not raised by the grid, because the grid is consuming those events, not initiating then.
So you need to hook events on your BindingSource, not the on grid. You might have to just cast the BindingSource to an IBindingList.
Boris,
Thanks for your reply. I'm a bit "disappointed" I have to implement such a workaround after noticing the existence of the BeforeRowsDeleted and AfterRowsDeleted events; I truly hoped they would fire :-). But your workaround will suffice for what I need.
After spending sometime researching this I can recommend you to hook to the 'Validating' event of the 'WinGrid' and compare it's current Rows collection's state with the state before the deletion.
I would recommend you to stick with the events of the BindingList if possible.
Please feel free to let me know if I misunderstood you or if you have any other questions.