Tab Controls and Tab Pages |
|
Tab Control Selection |
Many of the effects you will need on pages have to be set on the TabControl control and not on individual pages. This means that, to manage the characteristics of pages, you will change the properties of the parent TabControl control. At any time, whether working on the TabControl control or on one of its tab pages, you should first know what object you are working on by selecting it. To select the TabControl control itself, you have three main options:
|
At run time, neither the user nor you would really need to select a tab control. On the other hand, with code, you can refer to the tab control using its name.
Before manipulating a tab page, you must first select it. You various options:
As described in our introduction, to select a property page, the user can click its tab. To programmatically select a tab page, you have various options. We mentioned already that the tab pages are added cumulatively. The application keeps track of their position. To keep track of the positions of the tab pages, the TabControl class is equipped with a property named SelectedIndex. Based on this, to select a tab page using its position, assign the desired index to this property. Here is an example: Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click TabControl1.SelectedIndex = 1 End Sub You can also call the TabControl.SelectTab() method. In this case, pass the tab index to the method. An alternative is to select a tab page using its object name. To support this, the TabControl class is equipped with the SelectedTab property. Using it, to select a tab page, assign its name to the SelectedTab property. Here is an example: Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles Button1.Click TabControl1.SelectedTab = TabPage3 End Sub You can also call the TabControl.SelectTab() method. In this case, pass the name of the tab to the method. Both the TabControl.SelectedIndex and the TabControl.SelectedTab property are read/write. This means that, besides selecting a property page, you can use them to find out what tab page is currently selected. To do this, simply get the value of the control at the time you are accessing it.
|
|
||
Previous | Copyright © 2008-2016, FunctionX, Inc. | Next |
|