From Xojo Documentation

Class (inherits from PagePanel)

Used to organize controls into groups of tabs that can be selected by the user. Only the controls on the selected tab are visible.

Change DropObject MouseEnter
Close GotFocus MouseExit
ConstructContextualMenu KeyDown MouseMove
ContextualMenuAction KeyUp MouseUp
DragEnter LostFocus MouseWheel
DragExit MouseDown Open
DragOver MouseDrag

Active fa-lock-32.png LockRight SmallTabs fa-lock-32.png
AutoDeactivate LockTop TabIndex
Enabled MouseCursor TabStop
Handle fa-lock-32.png MouseX fa-lock-32.png Top
Height MouseY fa-lock-32.png Transparent
HelpTag Name TrueWindow fa-lock-32.png
Index fa-lock-32.png PanelCount fa-lock-32.png Value
Left PanelIndex Visible
LockBottom Parent Width
LockLeft Scope fa-lock-32.png Window fa-lock-32.png

AcceptFileDrop Caption Refresh
AcceptPictureDrop Close RefreshRect
AcceptRawDataDrop DrawInto Remove
AcceptTextDrop Insert SetFocus
Append Invalidate


Getting and Setting the displayed Panel

Use the Value property to get and set the tab panel being displayed. The first panel is numbered zero. Also, the PanelCount property of the PagePanel gives you the number of panels in the TabPanel. The TabPanel control is subclassed from PagePanel; the Value and PanelCount properties are described there.

You get or set the panel on which a control is located via the PanelIndex property of the Control class. The first panel is numbered zero.

The following line of code moves a ListBox from its current panel to the second panel of a PagePanel.

ListBox1.PanelIndex = 1

Adding, Labelling, and Renaming Tabs

Click the value of the Panels property of the TabPanel to display the Tab Panel editor. From this screen, you can:

  • Rename the existing tab labels by clicking twice on its name and editing the name.
  • Add tabs and their labels by clicking the Add button.
  • Delete any tab by highlighting it and clicking Delete.
  • Rearrange the tabs by highlighting a tab and clicking the Up or Down buttons.

You add controls to a particular panel by clicking its tab and dragging controls to that panel.

Placing Controls on Tab Panels

You can place other controls on the surface of any tab panel. Such controls are visible only when the user clicks on that panel's tab to bring it to the front. You can use the PanelIndex property of the Control class to read the panel on which the control is located.

Placing TabPanels within PagePanels (and vice versa) are not officially supported.

If the Caption property contains an ampersand character, it will display only if it is preceded by another ampersand character. This is done to make applications on all platforms behave consistently. The ampersand character is used to indicate the keyboard accelerator on Windows.

Controls placed on TabPanels are referenced in your code just by using the control name as if it were not on a TabPanel:

 PushButton1.Caption = "OK"

The TabPanel does not track the controls within it. You can retrieve an array of controls that are attached to a given index like this:

Function ControlsOnTabPanel(panel As TabPanel, panelIndex As Integer) As RectControl()

Dim tbControls() As RectControl

Dim wnd As Window = panel.Window
Dim lastIndex As Integer = wnd.ControlCount - 1
For i As Integer = 0 To lastIndex
Dim c As Control = wnd.Control(i)
If c IsA RectControl Then
Dim rControl As RectControl = RectControl(c)
If rControl.Parent = panel And rControl.PanelIndex = panelIndex Then
End If
End If
Next i

Return tbControls

End Function

See Also

RectControl class; PagePanel control.