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
In the next section, only essential properties of the TabStrip (gb.qt4) class are presented:
Property | DataType | Description |
---|---|---|
Text | String | Sets the text in the tab of the current tab or returns the text. |
Caption | String | Synonym for the property Text. |
Picture | Picture | Sets an icon in the tab tab of the current tab or returns the picture. |
Current | .TabStripContainer | Returns the current tab card. |
Index | Integer | Sets the index for the current tab page or returns this value. |
Property | Data type | Description |
---|---|---|
Count | Integer | Sets the number of register cards in the register or returns their number. |
Children | .Container.Children | Returns a collection of all controls in the register. |
Closable | Boolean | If the value is True, all tab controls get a close button. You can also read out the value. |
Orientation | Integer | Sets 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!
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.
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.
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.
Property | DataType | Description |
---|---|---|
Text | String | Sets the text in the tab of the tab card or returns the text. |
Caption | String | Synonym for the property Text. |
Children | .TabStripContainer.Children | Collection of all components on the tab card. |
Enabled | Boolean | Indicates with the value 'True' whether the tab map is active. |
Visible | Boolean | Indicates with the value 'True' whether the tab map is visible. |
Picture | Picture | Sets 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.
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:
Figure 12.6.0.5.1: Tab 3 exists - but is not displayed
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.