# Programming with Tab Controls

You can use the tab control functions to create and interact with a tab control programmatically.

## Creating a Tab Control and Adding Tab Pages

To create a tab control, use NewCtrl and specify CTRL_TABS as the controlStyle parameter. Use InsertTabPage to add tab pages to the tab control.

When you add a tab page to a tab control, LabWindows/CVI automatically creates a panel that is associated with this tab. You can call GetPanelHandleFromTabPage to obtain a panel handle for the tab and then pass that panel handle to the NewCtrl function as the panelHandle parameter to create controls on the page, and you can pass that panel handle to other functions that you can use to customize the controls.

## Customizing the Appearance of a Tab Control

You can use SetCtrlAttribute to customize the appearance of the tab control.

By default, tabs appear in the top left corner of the tab control. You can configure them to appear in the top right, bottom left, or bottom right corners. When you place the tabs in these locations, the text is horizontal. You also can configure the tabs to appear on the right or left side of the tab control at the top or bottom of the tab. When you place the tabs in these locations, the text is vertical. Use the ATTR_TABS_LOCATION attribute to configure the location of the tabs.

Use the ATTR_TABS_FIT_MODE to customize how the tabs appear on the tab control. By default, the tabs appear in a single row aligned to the left, right, top, or bottom side of the tab. You can specify that the tabs appear in a single justified row, in a single row with a scroll button to view tabs that do not fit across the tab control, or in multiple rows.

## Controlling a Tab Page Programmatically

You can use MoveTabPage to rearrange the tab pages in the tab control. Use CopyTabPage to make a copy of a tab page so that you can insert it in another location on the same tab control or on a separate tab control. To obtain the tab page that contains a specified point on a user interface panel, use GetTabPageFromPoint. You also can specify and obtain the active tab page with SetActiveTabPage and GetActiveTabPage.

## Removing a Tab Control

To remove a tab page from the tab control, use DeleteTabPage. You can remove up to all of the tab pages by passing -1 to the numberOfTabPages parameter.