LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to select which page in a tab control is displayed programmatically. I don't wish to hide tabs, just choose which is on top.

Create a property node.
Change the node to write.
Select "Value" on the node.
Create a control or constant from that node.
It will be an enum of the names of each tab.
Message 2 of 20
(7,377 Views)
Simplest way:
- right-click the tab control, choose 'create constant' to create the enum
- create a local variable for the tab control (not necessary if a tab indicator)
- wire the desired case of the enum to the local variable (or the tab indicator)

Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 3 of 20
(7,377 Views)
If you are not going to use the tab as a control, it is even simpler to just change the tab from "control" to "indicator".
www.vartortech.com
Message 4 of 20
(7,377 Views)
Grrr that was so easy. I can't believe I didn't think of that. Thanks a lot.
0 Kudos
Message 5 of 20
(7,377 Views)

Roberto is correct but rather terse.  It took me half an hour to figure out what he meant.

 

1.  You need to know which integer the tab control associates with each tab.  That is what generating the enum provides you.

The enum is not used in the program.

2.  Wire that integer as a numeric constant to the input of a Local Variable configured as write.

3.  When that part of the program is executed, the tab page associated with that integer will be displayed.

 

For example, tabs were enumerated as 0 - Calibrate, 1 - Run, 2 - Pause, 3 - Results

 

     2 --------  Tab Control

 

causes Pause to be on top when that part of the code is executed.  

A programmatically determined variable can be used in place of the constant.

 

It's simple but by no means obvious.

0 Kudos
Message 6 of 20
(6,808 Views)

 


@wildcatherder wrote:

Roberto is correct but rather terse.  It took me half an hour to figure out what he meant.

 

1.  You need to know which integer the tab control associates with each tab.  That is what generating the enum provides you.

The enum is not used in the program.....

 


The enum is used in the program. You can also first create the local and right click and select Create>Constant.

 

 

0 Kudos
Message 7 of 20
(6,789 Views)

Please think about your user experience.  Users tend to expect tabs to be controls.  If you make the tab an indicator, the user will not be able to change tabs by clicking on the tab.  If you want the navigation between tabs to be controlled by the program and not the user, it may be better to make the tab an indicator and then hide the tabs.  If you want both user and programmatic control, use the local variable.  Be careful that the program and the user do not get into a battle over which is controlling a tab: This will make a very frustrated user.

 

Lynn

 

 

Message 8 of 20
(6,777 Views)

In my applications, I usually initialize the currently visible tab when the application starts and then let the user control what they are looking at.  One thing to keep in mind is that if you right-click the tab control to create a constant enum, that enum will become invalid if you add or delete tabs on you tab control.  A bit of a nuisance at design time.  I know it is horrible, but I usually wire an integer to the tab property node (zero for instance to show the first tab in the control) and let it be cast to a tab enum value.  This will not break during design time as you add and remove tabs from the control.

-cb

Message 9 of 20
(6,758 Views)

@10Degree wrote:

In my applications, I usually initialize the currently visible tab when the application starts and then let the user control what they are looking at.  One thing to keep in mind is that if you right-click the tab control to create a constant enum, that enum will become invalid if you add or delete tabs on you tab control.  A bit of a nuisance at design time.  I know it is horrible, but I usually wire an integer to the tab property node (zero for instance to show the first tab in the control) and let it be cast to a tab enum value.  This will not break during design time as you add and remove tabs from the control.

-cb


Actually, you could break your code.  Suppose you want your new tab to be in the middle of some existing tabs, now all the higher number tabs need their constants updated.

 

If you are worried about enum constants breaking by adding new tabs, then you should make the enum a typedef.  (Or perhaps it is making the tab control itself a typedef.)  One thing I can't remember is that if there were any bugs reported about tab controls being typedefs causing programmers problems.

0 Kudos
Message 10 of 20
(6,749 Views)