LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically select page of tab control

Solved!
Go to solution

I have determined a solution that works for me:

For programmatically selecting a page of a tab control, I don't like to have to delete and recreate an enum constant of the page to navigate to after adding or removing pages to the tab control. I used to turn the tab control into a typedef. But a typedef tab control is hard to work with at design time (hard to select a group of fp controls, etc.).

 

I realized that I could create and maintain a typedef enum that has a copy of the tab page names. I have created a vi that receives the reference of the tab control and an enum (a value of the typedef enum that has a copy of the tab page names). When pages are added to or removed from the tab control, I edit the typedef to match the page names.

Download All
0 Kudos
Message 1 of 8
(1,750 Views)
Solution
Accepted by topic author Hamilton_Woods

The way you did this is fragile, you are coercing the enum to a number. The enum could be anything, doesn't have to match your tab pages. Something like this may be better.

 

snip.pngsnip2.png

0 Kudos
Message 2 of 8
(1,715 Views)

I like that! I agree that yours is better. Do you mind if I "borrow" from you?

0 Kudos
Message 3 of 8
(1,703 Views)

@Hamilton_Woods wrote:

I like that! I agree that yours is better. Do you mind if I "borrow" from you?


That's why it is posted, to use.

0 Kudos
Message 4 of 8
(1,689 Views)

@Hamilton_Woods wrote:

 

I realized that I could create and maintain a typedef enum that has a copy of the tab page names. I have created a vi that receives the reference of the tab control and an enum (a value of the typedef enum that has a copy of the tab page names). When pages are added to or removed from the tab control, I edit the typedef to match the page names.


No, that's still too complicated. What you need to do is make the tab control itself a typedef, then create constants of it (they look like enums). Now you would just edit the tab control typedef to add, remove etc. tab pages and all constants will follow.

 

Can you explain why you write to a signaling value property? A plain value property or a local variable of the tab control would be sufficient unless you have events that react to a tab page change. Also, if the tab should not be operated by the user directly, hide the tabs and make it an indicator to wire the new page directly to the tab terminal.

 

Edit: you mentioned this in your first paragraph, but I don't understand your "hard to select..." comment. I don't understand when that would be needed at all.

0 Kudos
Message 5 of 8
(1,617 Views)

altenbach, I was way too terse in describing the issues that result from creating a typedef of the tab control. I find it very difficult to work with a tab control after it has been turned into a typedef. Some of the issues are: 1) the only way to select a group of controls on a tab page is to individually select them. Trying to select them by using a rectangle either a) only selects the tab control, if the rectangle is started outside of the tab control, or b) only moves the tab control, if the rectagle is started in the tab page; and 2) if the tab control is inadvertantly resized by moving or resizing a control within a page, the only way to get the size back to the original without undos is to open the typedef and resize the control, which sometimes causes the controls to not be in their original positions.

 

My thought was to help anyone who has encountered the difficulties that I have encountered. Perhaps my experience is unique, in which case working with a tab control that has been turned into a typedef is not problematic for anyone else. If this is the case, maybe someone can help me know what I am doing wrong.

 

You are correct. I did not need to wire to the Value (signaling) property; I could have wired to the Value property.

0 Kudos
Message 6 of 8
(1,526 Views)

@Hamilton_Woods wrote:

 a) only selects the tab control, if the rectangle is started outside of the tab control, .


I can easily select all controls on a page by starting outside (e.g. at the star in the picture, then selecting towards the lower right corner.

 

altenbach_0-1690275442810.png

 

One problem is that you need sufficient temporary "parking space" on the toplevel diagram before dropping them on a different empty tab.

 

Yes, if you add or reorder tabs in the typdef, the contents don't follow and AFAIK there is no "swap content between two pages", for example. Maybe there could be a plugin....

 

I actually never run into problems because I typically plan ahead and create sufficient pages in the right final order. I might even add pages for future expansion that will be hidden or disabled until implemented. I also disable autosizing of tab pages

0 Kudos
Message 7 of 8
(1,501 Views)

@altenbach, thanks for teaching me and helping me out. I see now that I was not precise enough. I make it standard practice to assign typedefs to be strict typedefs. That is what I had done. When I make a typedef of a tab control and do not assign it to be a strict typedef, I get the behavior that you describe. I can select control elements in a group using a rectangle that starts either in the tab page or off of the tab page. Apparently the difference is between typedef and strict typedef. Also, I was not aware of the autogrow flag of a tab control. Old dogs (gosh, am I an old dog?) and new tricks!

 

Incidentally, even if I planned ahead (I'm not claiming that I do) my customers are prone to wanting to add new features over time. That is when new tab pages get added. Unfortunately, I cannot predict from the beginning how the software will evolve, so I attempt to design in a manner that allows for changes that do not break existing code.

 

I have a suspicion that I could learn a lot from you.

0 Kudos
Message 8 of 8
(1,475 Views)