User Tools

Site Tools


k12:k12.6:start

12.6.0 Class TabStrip

The class TabStrip (gb.qt4) implements a tab control. The advantage of this control is to map several dialogues of a programme on individual tabs located one behind the other and to realise a fast navigation via the tabs tabs.

The next picture shows the compact programme interface for the administration of a server, where, for example, over 35 tabs were used in 13 tabs:


Figure 12.6.0.1: Programme for the administration of a school server

12.6.0.1 Properties

In the next section, only essential properties of the TabStrip (gb.qt4) class are presented:

PropertyDataTypeDescription
TextStringSets the text in the tab of the current tab or returns the text.
CaptionStringSynonym for the property Text.
PicturePictureSets an icon in the tab tab of the current tab or returns the picture.
Current.TabStripContainerReturns the current tab card.
IndexIntegerSets the index for the current tab page or returns this value.
PropertyData typeDescription
CountIntegerSets the number of register cards in the register or returns their number.
Children.Container.ChildrenReturns a collection of all controls in the register.
ClosableBooleanIf the value is True, all tab controls get a close button. You can also read out the value.
OrientationIntegerSets the orientation of the tabs to left, right, top or bottom or returns this value. The default is 'top' - preset via the constant 'Align.Top'. These four constants can be used: Align.Top, Align.Bottom, Align.Left or Align.Right.

Table 12.6.0.1.1 : Properties of the class TabStrip

Note that the properties in the upper part of the table always refer to the current tab!

12.6.0.2 Methods

Of the methods of the TabStrip class, only this one is interesting:

TabStrip.FindIndex (gb.qt4)
Function FindIndex (Child As Control) As Integer

Use this method to find the index of the specified control in a tab. If the control is not found, -1 is returned as the function value.

12.6.0.3 Events

The Close(Index As Integer) event of the TabStrip class is only raised when a particular tab is closed. This assumes that the TabStrip.Closable property has been set to the value 'True' (default is 'False'). The index of the tab card to be closed is passed as the argument.

12.6.0.4 .TabStripContainer

The virtual class .TabStripContainer represents a tab card in a TabStrip component (Register). You can use a TabStrip like an array to get an object of the class .TabStripContainer (i.e. a tab map) via its index. The class .TabStripContainer has six properties and has only one method.

PropertyDataTypeDescription
TextStringSets the text in the tab of the tab card or returns the text.
CaptionStringSynonym for the property Text.
Children.TabStripContainer.ChildrenCollection of all components on the tab card.
EnabledBooleanIndicates with the value 'True' whether the tab map is active.
VisibleBooleanIndicates with the value 'True' whether the tab map is visible.
PicturePictureSets an icon in the tab of the tab map or returns the picture.

Table 12.6.0.4.1 : Properties of the virtual class .TabStripContainer

The Delete method deletes the current tab.

12.6.0.5 .TabStripContainer.Children

The virtual class .TabStripContainer.Children represents a collection of all components on a tab map. This class has only one property: Count, which returns the number of components on a tab card. However, bear in mind that, for example, in the case of a container component, only this container component is counted, but none of the components in the container!

You can iterate over all components on the tabs of a register and, for example, have the names of the components output. In Project1 of Chapter 12.6.1, this is exactly what is realised and provides this result → Figure 12.6.0.5.2 if, for example, a tab card is not visible in a register:

B2
Figure 12.6.0.5.1: Tab 3 exists - but is not displayed

B3
Figure 12.6.0.5.2: Display of selected tab properties.

Use this source code snippet to display selected register properties in a MessageBox or in the Gambas IDE console:

Public Sub btnGetInformations_Click()
  Dim i, k As Integer
  Dim hControl As Control
  Dim sMessage As String
 
  sMessage = "<hr><b><font color='Red'>Tab-Properties</font></b><hr>"
  For i = 0 To TabStrip1.Count - 1
    sMessage &= "<font color='Blue'>Index = " & CStr(i) & "</font>"
    sMessage &= "<br>Tab-Map-" & CStr(i + 1) & "-labelling =  '"
    sMessage &= TabStrip1[i].Caption & "'"
    sMessage &= "<br>Tab-Map-" & CStr(i + 1) & "  activated? " & String.Chr(10230)
    sMessage &= IIf(TabStrip1[i].Enabled = "T", " Yes", " No")
    sMessage &= "<br>Tab-Map- " & String.Chr(10230)
    sMessage &= IIf(TabStrip1[i].Visible = "T", " Yes", " No")
    sMessage &= " <br>Number of control elements on the " & CStr(i + 1)
    sMessage &= ". Tab-Map = " & CStr(TabStrip1[i].Children.Count)
    k = 1
    For Each hControl In TabStrip1[i].Children
      sMessage &= "<br>" & CStr(k) & ". Control item-Name = '" & hControl.Name & "' "
      Inc k
    Next
    sMessage &= "<br><hr>"
  Next
  Message.Info(sMessage)
 
' Displaying the information in the console in the IDE
' For i = 0 To TabStrip1.Count - 1
'   Print "Index = "; i
'   Print "Tab Map-"; i + 1; "-Label = "; "'"; TabStrip1[i].Caption; "'"
' Print "Tab Map-"; i + 1; " activated? --> "; TabStrip1[i].Enabled
' Print "Tab Map-"; i + 1; " visible?  --> "; TabStrip1[i].Visible
' Print "Number of control elements on the "; i + 1; ". Tab Map = "; TabStrip1[i].Children.Count
'   k = 1
'   For Each hControl In TabStrip1[i].Children
'     Print k; ". Control item-Name = "; "'"; hControl.Name; "'"
'     Inc k
'   Next
'   Print
' Next
 
End ' btnGetInformations_Click()

Note: If you have the mouse over a tab at runtime, you can use the mouse wheel to navigate through the individual tabs.

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k12/k12.6/start.txt · Last modified: 01.02.2022 (external edit)

Page Tools