操作方法:访问 TabStrip 控件中的某个选项卡How to: Access a Tab in a TabStrip Control

以下示例访问以下几种方式**TabStrip** 的单个选项卡:The following example accesses an individual tab of a TabStrip in several ways:

  • 使用**Tabs** 集合与数值索引。Using the Tabs collection with a numeric index.

  • 使用单个**选项卡** 的名称。Using the name of the individual Tab.

  • 使用**SelectedItem** 属性。Using the SelectedItem property.

若要使用本示例,请将此示例代码复制到窗体的"脚本编辑器"中。To use this example, copy this sample code to the Script Editor of a form. 要运行此代码,您需要打开窗体,以便将激活的项目的打开事件。To run the code you need to open the form so the Open event of the item will activate. 请确保该窗体包含一个名为"TabStrip1"的 TabStripMake sure that the form contains a TabStrip named TabStrip1.

Sub Item_Open() 
 Dim TabStrip1 
 Dim TabName 
 
 Set TabStrip1 = Item.GetInspector.ModifiedFormPages.Item("P.2").Controls("TabStrip1") 
 For i = 0 To TabStrip1.Count - 1 
 'Using index (numeric or string) 
 MsgBox "TabStrip1.Tabs(i).Caption = " & TabStrip1.Tabs(i).Caption 
 MsgBox "TabStrip1.Tabs.Item(i).Caption = " & TabStrip1.Tabs.Item(i).Caption 
 
 'Use Tab object without referring to Tabs collection 
 If i = 0 Then 
 MsgBox "TabStrip1.Tab1. Caption = " & TabStrip1.Tab1.Caption 
 ElseIf i = 1 Then 
 MsgBox "TabStrip1.Tab2. Caption = " & TabStrip1.Tab2.Caption 
 End If 
 
 'Use SelectedItem Property 
 TabStrip1.Value = i 
 MsgBox " TabStrip1.SelectedItem.Caption = " & TabStrip1.SelectedItem.Caption 
 Next 
End Sub