LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to enable/disable multiple front panel controls

Hi all,

 

In many of the programs I've written it seems to come up that I want to programmatically enable/disable/hide a group of controls based on user input.  In the past I've often ended up initializing an array of references to the controls for each group at the beginning of my code and then passing these arrays into a for loop whenever I needed the controls changed.

 

This method seems messy to me and I was wondering if anyone had a suggestion of a better way to go about this.

 

Thanks in advance.

Message 1 of 18
(15,792 Views)

That's the way I would do it.  If needed, you could do some of this in a subVI so that you can hide some of the activity.  Create an Action Engine that builds the array of refernces and stores them.  Then when needed, call the action engine to enable or disable your array of controls.

 

The only other possibility would be if a group of controls are inherently related that they should be a part of a cluster, in which case you just enable/disable the cluster.

0 Kudos
Message 2 of 18
(15,777 Views)

One other method is to pass an array of strings town to a subvi that will find a pane.controls[] by the lable.text then disable or enable the control, this is less coding but is more error prone since changing a control label requires updating the strinmgfs in the program.

 

I have used both over the years.

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 18
(15,773 Views)
Adding yet another possibility, I use Tab Controls (visible and invisible) many times when I want to selectively hide groups of controls. Works great, and for those controls you want visible in all frames, simply move them over the Tab control with the arrow keys instead of the mouse and they will float on top. Sometimes I'll even add redundant controls on the Tab pages with fixed enable/disable property instead of dealing with the property node.
0 Kudos
Message 4 of 18
(15,771 Views)

I use the same method as mentioned by "falkpl". It works great with me but the only problem with the  deletion of FP controls/indicators. To prevent  conflicts due to control names changes i search and disable them based on the caption names

Regards
Guru (CLA)
0 Kudos
Message 5 of 18
(15,763 Views)

When I make a GUI, I usually create a cluster of strict references for all the visible front panel objects.  I make this a typedef (so it can be easily modified) and use it as input to subVIs which enable/disable/move/resize controls.  It is the subVIs which define the behavior.

 

Note that using control references is the slowest way to set values, so is not recommended.

Message 6 of 18
(15,756 Views)

One other really cool method I have recently been exploring that use scripting (YES THIS IS ALLOWED IN 2010!)

is using the tag method.  Every control has a metadata section called tags which is essentially a string,variant pair for adding all sorts of information to your control.  This is a method of all controls so it can be used in a generic manor.  You can use this to define groups of behaviors for all controls.  There is some setup required for this but does open the possibility of doing some neat generic property setting.

 

When I have used this more (and have the time) I will try to post a nugget on it.

 

If this was exposed on the properties page it would be very cool (but it is not).

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 7 of 18
(15,740 Views)

A very fast and easy way to disable/enable multiple controls on a FP is to use an invisible (as in colored using all transparent colors) string control that is disabled. If your controls are all located in the same region of the FP place them under this invisible control. Simply hide or show this control to enable/disable all everything that is under it. If you do use this approach make sure to document it on the block diagram. This definitely is not as elegant as some of the proposed suggestions but it works quite effectively.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 18
(15,731 Views)

Here are two utilities which make it very easy to create both the array of references and the cluster of references:

 

https://decibel.ni.com/content/docs/DOC-5678

 

https://decibel.ni.com/content/docs/DOC-5813


___________________
Try to take over the world!
0 Kudos
Message 9 of 18
(15,718 Views)

 


@Ravens Fan wrote:

That's the way I would do it.  If needed, you could do some of this in a subVI so that you can hide some of the activity.  Create an Action Engine that builds the array of refernces and stores them.  Then when needed, call the action engine to enable or disable your array of controls.

 

The only other possibility would be if a group of controls are inherently related that they should be a part of a cluster, in which case you just enable/disable the cluster.


 

There is more than 1 school of thought on the subject.  I tend to use Raven's Fans approach an create an AE for groups of FP Objects and let the AE mainage the referances and act on the control's "Visable" and / or "enabled" properties.  You can do this a number of ways by either calling the AE when things change and you want to change whats showing on th GUI or you might even register an event so the AE can just do its thing when things change.

 

Serendipity time!

Just this morning the same topic was being discussed in the Community Nugget Series: Application development- Installment 2  Where Ben and I are commenting on "Show Hide Controls.vi" that is a AE within the system for preforming this exact function.


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 18
(15,708 Views)