I'm not really sure how to accomplish this task and would like some help with ideas or, if someone knows how to do this, some advice would be greatly appreciated!
I am working on a custom usercontrol. The usercontrol has a listbox (or rather it IS a listbox, just docked to fill the control surface), anyway, I need to catch/intercept when a user changes the selected index of the listbox in the control. The listbox is bindable (it has the DataSource, DisplayMember, SelectedValue and ValueMember properties exposed) and the binding works great! However, I want to give my control two custom events, one that executes when the selected index is about to change but before it has, and one after the selected index has changed.
I know how to implement custom events, that's not the problem, the problem is that since the listbox control does not have an event for selectedindexchanging and only one for selectedindexchanged, I can't seem to figure out the best way to "intercept" the index change before it actually occurs.
I don't know if that actually makes much sense, I hope it does.
Also, since the control I am creating has a base of UserControl and not ListBox the listbox events and properties are not exposed when the usercontrol is added to the design surface, and they are not editable in code. I would need to implement them on my own to make them public, which is exactly what I want, but I need some of the listbox events to be accessable, so they can be subscribed to.
To get to where I am just create a custom usercontrol, and when the design surface appears for that control, throw a listbox on it, and now imagine you want to find out when the selected index on that listbox is about to change and when it has changed. That's about the extent of it. I'm not sure where to start. The selectedindexchanged event already exists, so that's an easy one, but knowing before the change occurs is the show stopper for me.
Any help would be greatly appreciated!