I need to determine which tab the user is coming from, and going to, when they switch tabs, and possibly cancel the switch. I have tried the Deselecting, Deselected, Selecting, Selected events, and all of them show the e.TabPageIndex to be the same as the sender.SelectedIndex.
Is there an event, or property, that I can use so that I can determine both sides of this, or do I have to hack something together with caching it from one event and using that value in the new event.
I am trying to avoid handling the Deselecting/Deselected events and caching the value to use in the Selecting event. I already know I can do this, so I am asking if there is a cleaner way, without doing this.
I have tried in both C# and VB, with the same results (no surprise).
Thanks.
It doesn’t look like any one event argument will carry the details of both the previous and current tabs, so you’ll need to handle a couple of events to keep track.
At a minimum, you’d need to use the
Deselectedevent to store a reference to the previously-selected tab. You can always query the TabControl for its current tab. To stretch a little further, you can also handle theSelectedevent to track the current tab.