Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form to a specific tab

Status
Not open for further replies.

Sandman83

Programmer
Sep 11, 2001
122
US
Hi All,

First off I am pretty new to VB.Net. I used to code in VB.Old (VB 6) and VBA. I am trying to learn by building a fairly simple project and like to throw a few somewhat advanced (or at least new to me) concepts in to keep it interesting.

Currently I have a main form and a config form. On the main form I have a menu strip with a "Config" item. The Config item has several items beneath it. On the config form I have a tab control with several tabs. What I want to accomplish is when an item under the Config menu is selected, the config form opens and automatically goes to the tab associated with the config item that was selected.

Is there a shortcut in VB.Net that will do this? Or do I need to pass a variable to the config form and run some code on the load event of the config form. If I need to run some code, what is the command to select a specific tab?

Thanks in advance for any and all help,

Tim
 
There is no direct linking the two so you would have to either:

1) Pass a variable to the form and run code.
2) Read a variable from the main form in the load event.
3) Create a new instance of the option form on the correct tab each time you open it.
4) A thousand other ways you could do it.

The line for the first tab could be done like:
TabControl1.SelectedTab = TabControl1.TabPages(0)

-I hate Microsoft!
-Forever and always forward.
 
Thanks Sorwen,

I went with a global variable of type uShort then used the following code in the load event.
Code:
TabControl1.SelectedTab = TabControl1.TabPages(TabNum)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top