Jump to content

How to programatically add pages to a tab control?


Recommended Posts

I need to build a tab control with many pages (I won't say how many because someone will surely scold me). I'm too lazy to go through and keep doing "Add page after". Is there another way to do this? I've searched through all the invoke and property nodes. There was an entry at NI for doing this with Labwindows, but that doesn't help.

George

Link to comment

I need to build a tab control with many pages (I won't say how many because someone will surely scold me). I'm too lazy to go through and keep doing "Add page after". Is there another way to do this? I've searched through all the invoke and property nodes. There was an entry at NI for doing this with Labwindows, but that doesn't help.

George

Well I think the NI LabVIEW APIs (scripting) toolkit should be able to do that.

Ton

Link to comment

I need to build a tab control with many pages (I won't say how many because someone will surely scold me). I'm too lazy to go through and keep doing "Add page after". Is there another way to do this? I've searched through all the invoke and property nodes. There was an entry at NI for doing this with Labwindows, but that doesn't help.

George

Scripting gives you Invoke Node > Add Page. But if you want to create an executable I don't know what you can do except what I've done in the past and that is to create as many tab pages as you think you will ever need and make them visible/invisible using the Pages array and page visible properties. It sounds kind of clunky but that's all I can offer.

Edited by PaulG.
Link to comment

George

I would strongly suggest that you investigate another option involving sub-panels and utilizing a listbox to choose the appropriate 'Page' (something like the LV Options page)

Although tabs afford the user some good user interactivity points, it is limiting when attempting something more dynamic which it sounds like your doing.

You will find that a listbox with subpanels are extremely more flexible albeit a hair more exotic with the process of getting information from the subpanels back to the top level.... but that is another discussion altogether with a variety of very good solutions.

If you CAN NOT live without a tab control, you will still need to use sub-panels anyway and you would create the sub-panel VI on the fly with scripting and adding / removing tabs that way. (a creative yet very flawed solution)

Good luck

~,~

Norm Kirchner

  • Like 2
Link to comment

Tab controls have a fixed number of pages compiled into them. If you're not working in the development environment, you cannot add more pages. And even if you are in the dev environment, you cannot add more pages while the VI in question is reserved for run.

The only workaround I can think of might not be too appealing: You could drop a picture control and draw your own tabs. (Note that Norm's alternative is a better solution generally... I was just trying to workaround the "you need tabs" problem, not solve the wider UI issue...)

Link to comment

I would strongly suggest that you investigate another option involving sub-panels and utilizing a listbox to choose the appropriate 'Page' (something like the LV Options page)

Here's an example of exactly that - a subpanel controlled by a list of categories (subVIs that are loaded into the subpanel). It's a half-arsed job that I was mucking around with, so use at your own risk. There are three VIs: the preferences dialog itself, a template preferences page and an example preferences pages (there are some OpenG dependancies that you'll need too). One added bonus is that the preferences dialog saves an ini file of all the values on the FPs of the preference pages, and recalls them from that file each time you show the preferences dialog again. The implementation I had it in would look in a particular folder for any VIs with "prefpage_" at the start of it's name, and attempt to include it in the category list. The top bar updates to the title of the subVI too.

PreferencesDialog.zip

  • Like 1
Link to comment

I thinks it's no good idea to have many tabs. The user (as I always do) gets easily confused because the tabs are organized in rows above the main panel area and the order of the rows always changes if one clicks a tab in another row. I think using a listbox is the better style. And for three tabs its not worth while to make some scripting.

Link to comment

Really, in this case I need them.

Then you need to define an upper limit and do the fanciness of hiding/showing all tabs up to your limit and using tab-captions to dynamically re-name the visible tab names

(or do the hacky way of having a non-running VI present in the sub-panel that you can edit at runtime but not run)

If you resolve yourself to that, then you have a solution (which i'm sure plenty of others have done in the past to do this exact thing)

Link to comment

The only workaround I can think of might not be too appealing: You could drop a picture control and draw your own tabs. (Note that Norm's alternative is a better solution generally... I was just trying to workaround the "you need tabs" problem, not solve the wider UI issue...)

I actually saw a an example somewhere (maybe on NI website ) from somebody that created a Tab control using a picture control (this was prior to NI having a native tab control).

PJM

Link to comment

I need to build a tab control with many pages (I won't say how many because someone will surely scold me). I'm too lazy to go through and keep doing "Add page after". Is there another way to do this? I've searched through all the invoke and property nodes. There was an entry at NI for doing this with Labwindows, but that doesn't help.

George

Hi,

You could try downloading the scripting.vit from Labview API Group, then modify the "FP" case to something like this:

post-16028-124707654741_thumb.png.

Quick and (really) dirty, but seems to work.

This adds "Test1" to "Test5" as the first five pages of the selected Tab controls when the button is pushed (your tab controls parent vi, must be in edit mode). You will need to have scripting installed, due to the TabControl "Add Page" method.

Espen

Link to comment

Hi,

You could try downloading the scripting.vit from Labview API Group, then modify the "FP" case to something like this:

post-16028-124707654741_thumb.png.

Quick and (really) dirty, but seems to work.

This adds "Test1" to "Test5" as the first five pages of the selected Tab controls when the button is pushed (your tab controls parent vi, must be in edit mode). You will need to have scripting installed, due to the TabControl "Add Page" method.

Espen

I'm using LV8.6, but I can't find the "Add Page" Invoke node you are using for TabCtl anywhere. :frusty:

Link to comment

I'm using LV8.6, but I can't find the "Add Page" Invoke node you are using for TabCtl anywhere. :frusty:

I have not done anything spesial with Labview ini or anything like that. As long as you have Labview Scripting installed, and you are using a tab control refrence (I needed the "to more specific class" function), I can se no reason why you should not find it.

Espen

post-16028-124743432774_thumb.png

Link to comment
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.