Wednesday, June 2, 2010

Preventing Tabs from being Selected

I tried several solutions I found on the internet to prevent tabs from being selected with a TabControl, but the link below shows the only solution that worked well. My task was very simple, I didn't want the user to select other tabs until the first tab contained valid information. The trick was to use the Deselecting event on the TabControl. In the event, see which tab you are on (SelectedIndex) and perform your validation specific to the tab. If the validation fails, set the event's e.Cancel to True and the tab won't change.

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Studio_.NET_2005/Q_23411323.html

No comments: