LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to change properties for some controls in runtime ?

Solved!
Go to solution

hi,

I would like to change some of the properties for some controls in front panel in runtime. Number of control properties I want to change is depending of a log file user opens in final application.

 

I attach an example where I'm trying to change the visibility of numeric controls. Problem I have I don't know which reference to connect to property node in case the control in for loop is not a numeric control. The example relies to label.text property but I could use the more generic classname property as well.  

 

regards,

petri

  

0 Kudos
Message 1 of 10
(6,083 Views)

I'm sorry, I haven't been able to look at your code at the moment, don't have LabVIEW on this machine. I do recommend an thread that Ben started regarding using control references it has a lot of helpful/useful ideas and techniques.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 10
(6,070 Views)

Not sure exactly what you're trying to do.  But my guess is that you want something like the attached.

Message 3 of 10
(6,048 Views)

If you only need to operate on a well defined subset of controls, I would use an array fo direct controls and a boolean lookup table depending on the desired state, e.g. as follows.

Message 4 of 10
(6,043 Views)

 

thanks for quick reply! I think both solutions resolve my original problem. but I liked more pcardinale's solution because that collects one type of controls in one place. in my final application I want to control visibility of XYGraph types of controls in runtime.

 

next curious thing for me seems to be the contol's caption. Why I cannot set the caption text for a control in runtime before setting that control's caption visible in front panel ? see attached example. If I set numeric control's caption to visible I don't get error message for that control.

 

best regards,

petri

 

 

 

0 Kudos
Message 5 of 10
(6,031 Views)

If I remember well, captions don't exist already when the control is created but are created "on demand", that is you need to manually create a caption before accessing it programatically.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 10
(6,027 Views)

 

yes, in fact it states in help file:

 

"Note  You must first create the caption before you use this property, or LabVIEW returns an error. LabVIEW creates the caption the first time you set the caption to visible."

 

I tried even programmatically to set caption visible before setting caption text, but it didn't seem to create the caption in runtime. perhaps the only way is to set the caption visible in front panel.

 

best regards,

petri

  

 

0 Kudos
Message 7 of 10
(6,017 Views)
Solution
Accepted by topic author Petri

Initially, a control has no caption.  It's not just that the caption string is empty and the caption not visible, but the caption object does not exist.

 

At edit time, when a caption is set to anything other than an empty string, the caption object is created.  If you change the caption back to an empty string, the caption object is deleted.

 

At runtime, the caption object cannot be created or destroyed, but if it exists, it can be changed.

 

When I have captions that I want to change at runtime, I initially set them to ".".

0 Kudos
Message 8 of 10
(6,001 Views)

@paul_a_cardinale wrote:

Initially, a control has no caption.  It's not just that the caption string is empty and the caption not visible, but the caption object does not exist.


I think this should probably be changed in future versions, because even if each control had a caption, it would still be a negligible small part of the VI. The current behavior made sense many years ago where HD and memory space was very precious. Not any more!

 

This issue comes up often enough that it warrants addressing the root of the problem. 🙂

 

It is hard to convince the casual that the caption does not exist if he can simply do a "show caption" at edit time and it will show in all glory, even with the default set to the current label. It is confusing!

 

There is even an idea about this that seems worth supporting (also read the link in the discussion).

 

What do you think?

Message 9 of 10
(5,988 Views)

In my opinion, and as a new LV programmer learning all these tricks after decade of CVI experience, it is confusing that some of properties can only be created in edit time. As you wrote it makes no sense for today's PC, but perhaps in embedded systems may still have some HD and memory restrictions. My suggestion would be to introduce an overview of all these properties e.g. as form of a poster defining e.g. with different colours which properties are accessible only in edit time and which both in edit time and runtime. A good example of an overview for all objects has been shipped with TestStand updates. But I'm not sure if NI stopped to ship these posters and went over to electronical format instead, at least I have not seen such a poster in last updates.     

 

best regards,

petri    

0 Kudos
Message 10 of 10
(5,969 Views)