08-26-2010 02:16 PM
Given a name/value pair, how do I set a front panel control with the label name to a value of value?
This seems like it should be simple but I can't see it.
Solved! Go to Solution.
08-26-2010 02:21 PM - edited 08-26-2010 02:22 PM
I am assuming you are referring to a control on another VI. In that case you need to open a reference to that VI and then just use the Set Control Value method:

Note that I am using the variant version of that method. There is also one that works with flattened data. Please check the documentation for further details.
08-26-2010 02:22 PM
I would also read this.
http://forums.ni.com/t5/LabVIEW/Dr-Damien-s-Development-Setting-Front-Panel-Controls/m-p/1166255
08-26-2010 02:23 PM
You can not change the lable of a control when the program is running you need to change the caption text. You also need to ensure that you are displaying the caption on the control on the front panel.
Can be done easy with a propert node.
08-26-2010 02:25 PM - edited 08-26-2010 02:25 PM
What they said!
Ben
08-26-2010 02:32 PM
@aeastet wrote:
You can not change the lable of a control when the program is running you need to change the caption text. You also need to ensure that you are displaying the caption on the control on the front panel.
I don't believe the user is trying to change the label. I believe they're just trying to change the value.
Can be done easy with a propert node.
Of course, only if we're referring to the control being on the same VI. ![]()
08-26-2010 02:56 PM
I take the original question as this. Given a certain name/value pair, the OP wants to look for the control whose label matches name. When found, he wants to change the value of that control to value. For example, if there are two controls labeled CTRL1 and CTRL2, and his input is CTRL2/5.4, then he wants to change the value of CTRL2 to 5.4. If I am correct, here is the solution. Use methods and property nodes to get all controls, and look for the one whose label matches name. When found, change its value.
08-26-2010 03:03 PM
The Ctrl Val.Set method is perfectly happy to use the implied 'This VI' reference when the VI reference is left unwired and change the specified control value on the same VI as well as the previous example of doing it on a different VI.
08-26-2010 03:10 PM
Thank you all for your rapid-fire answers. The method proposed first is the one I was seeking. The link in the second post to Darren's nugget repeatedly referred to the property node for Control Value > Set, which doesn't exist. It should have said "invoke node".
Had I to do over again, I would have asked "Given two strings, one for the name of a control, and one for the value of the control, how do you set the value of control name to value value?" I think this adds a level of difficulty not presented earlier. I will sort out a way of making this work using the first example given. Thanks to all and if you have any comments on the revised question, please don't hesitate to reply to that one also.
This is why I love the NI LV forums. You all bust your bums to try to help each other.
Thanks.
08-26-2010 03:17 PM - edited 08-26-2010 03:19 PM
Do you mean this?