TabControl Undo Tab Changes

I use the TabControl_SelectedIndexChanged event when the user changes tabs. TabControl.SelectedIndex / TabControl.SelectedTab returns only a new tab. Is there any way to get the previous tab? Or should I stick to the obvious preservation of the current tab every time I change tabs?

I want to use this to undo tab changes under certain conditions, for example, there are unsaved changes.

+6
source share
2 answers

If you want to undo a tab change, you can use the Deselecting event. There you can undo the change by setting the Cancel property of the provided TabControlCancelEventArgs to true.

+15
source

Check out http://msdn.microsoft.com/en-us/library/system.windows.forms.tabcontrol.selected%28v=vs.80%29.aspx

There are events that are better suited to what you want to do.

+3
source

Source: https://habr.com/ru/post/902698/


All Articles