Alex Rivera | Logout

TabControl Cancel change of tabs

Asked 2011-11-29T20:22:55.497
9

I am using TabControl_SelectedIndexChanged event when the user change tabs. The TabControl.SelectedIndex / TabControl.SelectedTab return only the new tab. Is there any way I can get the previous tab? Or must I stick with the obvious store the current tab every time I change tabs?

I want to use this to cancel a change of tabs under certain conditions, like there is unsaved changes.

Edit
Report

1 Answer

22

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

answered 2011-11-29T20:28:03.237

Your Answer