TabPage overwhelming situation


May 2, 2005
Hialeah, FL
Programming Experience
I'm having a hard time finding a way to disable clicking between tab pages or even allowing the user to use the arrows to do this. If they do, they will encounter an error stating that they must finish editing, before they go to the next tabpage control. In a nutshell, how can I achieve this? When they click on any other tab, nothing will happen, rather what will happen is that the focus will remain on the current tab. And a messagebox will display indicating that the user must finish editing before they can browse to other tabs. Same principle with the keyboard. I been looking all over the place for a solution for this. How can this be accomplished? I will appreciate all the help that I can get. Thanks.
Sounds Like a Wizard


When I consider your question it reminds me of a multi tabbed wizard where you cannot go to the next tab until the previous tab has been filled out. Im sure this is not exactly what you are looking for but Im confident it will give you an idea or two.

The logic of this example will assume that you start on the first tab, and tabs that follow will be enabled as you progress, one at a time.

1. Place a TabControl on the the Form named TabControl1

2. Add to the Pages collection of the TabControl 3 Tab Pages named; TabPage1, TabPage2 and TabPage3.

3. Set the Enabled Property of TabPage1 to TRUE and set the Enabled Property of TabPage2 and TabPage3 to FALSE

4. Append the following line of code to the SelectedIndexChanded event of the TabControl
If TabControl1.SelectedTab.Enabled = False Then TabControl1.SelectedIndex -= 1

Now if you run this application you will notice that only TabPage1 will maintain focus. In order to access the other TabPages you will need to set the Enabled Property to TRUE.

I Hope that helps.

Richard Yager
If the user must complete one page at a time then I would suggest not using a TabControl at all, but rather puuting your Controls on Panels which you can hide and show with next and back buttons. Logically, you should be able to select any TabPage in a TabControl at any time.