简体   繁体   English

VB.NET中的选项卡控件

[英]Tab control in VB.NET

I'm doing my project and I design including many tab controls in VB.NET. 我正在做我的项目,我在VB.NET中设计了许多选项卡控件。

Example: 例:

I have 3 tab pages like tab1,tab2,tab3. 我有3个标签页,如tab1,tab2,tab3。 And I have menu bar to open tab1,tab2,tab3. 我有菜单栏打开tab1,tab2,tab3。

How can you use code to open each tab page? 如何使用代码打开每个标签页?

How do I solve this problem? 我该如何解决这个问题?

The simplest way is to just handle the OnClick event of your menu buttons and just doing: 最简单的方法是只处理菜单按钮的OnClick事件,然后执行以下操作:

Me.MyTabControl.SelectedTab = index;
// 0 = Tab1, 1 = Tab2, 2 = Tab3

Obviously you would replace index with whichever tab you wish to open. 显然,您将使用要打开的选项卡替换索引。

Incase you don't know how to handle the OnClick event, just double click on the button's and the OnClick event is automatically generated for you. 如果您不知道如何处理OnClick事件,只需双击按钮,就会自动为您生成OnClick事件。 Then per button_onclick you just put in the above code, with the index you wish to open when that button is clicked. 然后按button_onclick你只需输入上面的代码,单击该按钮就可以打开索引。

TabControl1.SelectTab(0) ' if you wanted to open the first tab in TabControl1 TabControl1.SelectTab(0)'如果要打开TabControl1中的第一个选项卡

TabControl1.SelectTab(1) ' if you wanted to open the second tab in TabControl1 TabControl1.SelectTab(1)'如果要在TabControl1中打开第二个选项卡

.............................................(2) ' .......................................................3rd...................... .............................................(2)'。 .................................................. .... 3 ......................

.............................................(3) ' .......................................................4th...................... .............................................(3)'。 .................................................. .... 4 ......................

etc. 等等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM