Set the Active Page of a Tab Control Programmatically in LabVIEW

Updated Jan 11, 2023

Environment

Software

  • LabVIEW Full
  • LabVIEW Base

I would like to programmatically set the active page of a tab control on my Front Panel. How can I do this?

If you only need to have an Enum control to switch between the tabs of a tab control, the easiest way is to make the Page Labels Display Visible. To do it, right-click any tab and select Visible Items » Page Labels Display.
Page Labels Display[.png
Figure 1. Tab control with the Page Labels Display Visible

The advantage of this method is that no extra terminals are created in the block diagram and that means less code to manage. Moreover, every time you create, rename or delete a tab, the values will be automatically updated on the Page Labels Display​​​​​​.

Nevertheless, if you need need a programmatic approach, to set the active page of a tab control in LabVIEW, you can change the tab control to an indicator, or use a local variable or a Value Property Node for the tab control.

To use tab control as an indicator:
  1. Right-Click the tab control terminal on the block diagram and select Change to Indicator.
  2. Right-click the input of the Indicator and select Create » Constant.
indicator.png
Figure 2. Tab control as an indicator

Note: When using this approach, no controls placed into the tab control's pages will be affected. Controls will still be controls and indicators will still be indicators. However, you won't be able to change tabs by clicking on them on the front panel anymore. 

To use a local variable:
  1. On the Block Diagram, right-click your tab control and select Create » Local Variable.
  2. If the local variable is not already set to write access, then right-click it and select Change to Write.
  3. Right-click the input of the local variable and select Create » Constant.
To use a Value Property Node:
  1. On the Block Diagram, right-click your tab control and select Create » Property Node»Value.
  2. If the Property Node is not already set to write access, then right-click it and select Change to Write.
  3. Right-click the input of the Property Node and select Create » Constant.
Figure 3. Programmatically Set the Active Page of a Tab Control

The created enum constant will automatically populate with the names of the pages in your tab control. By selecting one of these pages to write to your local variable, you can programmatically set it to be the active page of your tab control on the Front Panel. However, if you create, rename or delete a tab, the values will not be automatically updated on the enum constants.