We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Platform : Windows Forms
|
Category : TabControl

How do I prevent the user from changing the selected tab page?

You can use the TabPage’s Validating event to prevent a new tab page selection. Here are the steps:

1) Every time the user selects a new tab, make sure that the corresponding tab page gets the focus. You can do so as follows:

Note that CausesValidation should be set to True since you will be listening to the Validating event in the next step. You will also have to add some code like above when the TabControl is shown the very first time (like in the Form_Load event handler).

2) Listen to the TabPage’s Validating event (which will be called when the user clicks on a different tab page) and determine whether the user should be allowed to change the selected tab page.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.