[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

Manipulate TabControl from code

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).

1 Solution
To set focus I think it must work


on the TextBoxX leave event , change the tab page

Me.TabControl1.SelectedTab = Me.TabPage2
bhlangAuthor Commented:
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.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now