Using Tab controls

A Tab control is a container for tab pages that display other controls. You can add a Tab control to a window in your application to present information that can logically be grouped together but might also be divided into distinct categories. An example is the use of tab pages in the Properties view for objects in PocketBuilder.

NoteSmartphone platforms Tab controls are not supported on Smartphone devices or emulators.

When you add a Tab control to a window, PocketBuilder creates a Tab control with one tab page labeled “none”. The control is rectangular. By default, the tab label is at the bottom of the tab page.

Distinguishing tab controls and tab pages

Typically you use more than one tab page on a tab control. After you add a tab control with a single tab page to a window, you add as many tab pages as your application requires.

Each tab page displays a label that is visible even when a different tab page is selected. If the number of tab pages is too large to display all the tab pages, a miniature scroll bar is displayed on the screen at the level of the visible tab labels. The scroll bar enables users to scroll to hidden tab labels.

To select the Tab control at design time, click any of the tab labels, or click in the area adjacent to the tab labels but outside the current tab page.

To select a tab page, click its label and then click anywhere on the tab page except the label itself. Selection handles display at the corners of the tab page, but do not include the tab control labels. (When the tab control is selected rather than the tab page, the selection handles include the tab control labels.)

Adding tab pages to a Tab control

You can add a new Tab control to a window by selecting Insert>Control>Tab and clicking in the window. The control has one tab page when it is created. Use the following procedure to place additional tab pages in the tab control.

StepsTo create a new tab page in a Tab control:

  1. Select the Tab control by clicking on a tab label or in the area to the right of the labels when the labels display at the bottom or top of the tab pages.

    The handles that indicate that the Tab control is selected display at the corners of the Tab control. If you selected the tab page, the handles display at the corners of the area above the tab labels when the labels are at the bottom of the control.

    The pop-up menu for a tab page does not allow you to insert additional tab pages, only to modify the order of the controls on the selected tab.

  2. Choose Insert TabPage from the pop-up menu.

  3. Add controls to the new tab page.

Creating a reusable tab page

You can create reusable tab pages in the User Object painter by defining a tab page with controls on it that is independent of a Tab control. You can then add that tab page to one or more Tab controls.

StepsTo define a tab page that is independent of a Tab control:

  1. Click the New button on the PowerBar and use the Custom Visual icon on the Object tab page to create a custom visual user object.

  2. Size the user object to match the size of the Tab controls in which you will use it.

  3. To the user object, add the controls that you want to display on the tab page.

  4. Select the user object (not one of the controls you added) and on the TabPage page in the Properties view, specify the information to be used by the tab page:

  5. Save and close the user object.

Adding a reusable tab page to a Tab control

After you have created a user object that can be used as a tab page, you can add it to a Tab control. You cannot add the user object to a Tab control if the user object is open. After you have added the user object to the control, you also cannot open the user object and the window that contains the Tab control at the same time.

StepsTo add a tab page that exists as an independent user object to a Tab control:

  1. In the Window painter, right-click the Tab control.

  2. Choose Insert User Object from the pop-up menu.

  3. Select a user object that you have set up as a tab page and click OK.

    A tab page, inherited from the user object you selected, is inserted. You can select the tab page, set its tab page properties, and write scripts for the inherited user object just as you do for tab pages defined within the Tab control, but you cannot edit the content of the user object within the Tab control. If you want to edit the controls, close the Window painter and go back to the User Object painter to make changes.

Manipulating the Tab control

You can use the Layout view to open other views of the Tab control and to move, resize, or delete the Tab control.

StepsTo change the name and properties of the Tab control:

  1. Click any of the tabs in the Tab control to display the Tab control properties in the Properties view.

  2. Edit the properties.

    For more information, right-click in the Properties view and select Help from the pop-up menu.

StepsTo change the scripts of the Tab control:

  1. Double-click one of the tab labels or right-click a tab label and select Script from the pop-up menu.

  2. Select the Tab control event you want from the second drop-down list of the Script view and edit the script.

StepsTo move a Tab control:

  1. With the mouse pointer on one of the tab labels, hold down the left mouse button and drag to move the control to the new position

    The Tab control and all tab pages are moved as a group.

StepsTo resize a Tab control:

  1. Grab a border of the control and drag it to the new size

    The Tab control and all tab pages are sized as a group.

StepsTo delete a Tab control:

  1. With the mouse pointer on one of the tabs, select Cut or Delete from the pop-up menu

Manipulating the tab pages

You can use the Layout view to display any tab page in a Tab control, to open other views of the selected tab page, and to delete the selected tab page from the Tab control.

StepsTo view a different tab page:

  1. Click on the label for the tab page you want to view

    The selected tab page is brought to the front. The tabs are rearranged according to the TabPosition setting you have chosen for the Tab control.

StepsTo change the name and properties of a tab page:

  1. Select the tab.

    Selecting a tab can move it to the position for a selected tab based on the TabPosition setting for the Tab control. For example, if TabPosition is set to tabsonbottomandtop! and a tab displays at the top, it moves to the bottom when you select it.

  2. Click anywhere on the tab page except the tab label.

  3. Edit the properties.

StepsTo change the scripts of the tab page:

  1. Select the tab.

    It may move to the position for a selected tab based on the Tab Position setting for the Tab control.

  2. Click anywhere on the tab page except the tab label.

  3. Select Script from the tab page’s pop-up menu.

  4. Select a script and edit it.

StepsTo delete a tab page from a Tab control:

  1. With the mouse pointer anywhere on the tab page except the tab label, select Cut or Delete from the pop-up menu

Managing controls on tab pages

You can add and move controls on tab pages the same way you add and move controls on a window.

StepsTo add a control to a tab page:

  1. Choose a control from the toolbar or the Control menu, then click in the tab page where you want to add the control

    You can add controls only to a tab page created within the Tab control. To add controls to an independent tab page, open it in the User Object painter.

StepsTo move a control from one tab page to another:

  1. Cut or copy the control and paste it on the destination tab page

    The source and destination tab pages must be embedded tab pages, not independent ones created in the User Object painter.

StepsTo move a control between a tab page and the window containing the Tab control:

  1. Cut or copy the control and paste it on the destination window or tab page

    Moving the control between a tab page and the window changes the control's parent, which affects scripts that refer to the control.

    For more information on the Tab control, see the chapter on using tab controls in the Resource Guide.