Manipulate TabControl from code

Posted on 2004-11-19
Last Modified: 2012-05-05
I have a TabControl on a form with three tabs.
Each TabPage has a set of controls on it.

Here's what I want to know how to do with code:
1. When the form is loaded, set the Focus to the first TextBox where ReadOnly = False (some TextBoxes have ReadOnly = True)
2. When the user gets to the last TextBox on a TabPage and tabs out of that TextBox, Switch to the Next TabPage.

From the answers to these, I should be able to extrapolate how to do the reverse (ie. switch to the Previous TabPage and set Focus to the Last TextBox on a TabPage).

Question by:bhlang
    LVL 28

    Accepted Solution

    To set focus I think it must work


    on the TextBoxX leave event , change the tab page

    Me.TabControl1.SelectedTab = Me.TabPage2

    Author Comment

    Back in Visual Basic 6, if I were to set a TextBox with the focus in the Form Load event, then it would crash every time - the text box wasn't displayed for it to have the focus.

    So when I saw your first suggestion, I though that it would fail. But I tried it anyway, and whaddya know - it worked! Now the form loads with the field I want the focus in having the focus.

    And as for the second part, that's exactly what I was looking for.

    Thank you very much.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now