05-20-2018 02:43 PM
Hi,
I want to find control reference by label and later change it's color. The thing is I can't. I would love to know:
- why?
- how can I get reference which will allow me to do that?
05-20-2018 03:01 PM
The reference out of your code is of the type (generic) control. There is no common color property for all controls. Different types of controls have different color properties. If you know the type of a control, you can use the "To More Specific Class" function to cast it to the appropriate class, then access the color properties of the control.
05-20-2018 03:08 PM - edited 05-20-2018 03:29 PM
Thank you. Is there any way, to get the control type or do I have to know it myself?
There's also one thing I don't understand. If reference points to the exact control and it contains information like label why doesn't it contain information about control type?
05-20-2018 04:52 PM
@bartek618 wrote:
Thank you. Is there any way, to get the control type or do I have to know it myself?
You can get the control type, but that won't help you much. To be able to use a specific property, you need to convert to more specific. So although you can get the type, at some point you need a convert to more specific.
@bartek618 wrote:There's also one thing I don't understand. If reference points to the exact control and it contains information like label why doesn't it contain information about control type?
It does contain this information. For instance, there is a 'class name' property. So the reference 'knows' what it is.
It's basic OO really. Although you have a child object, if the class is a parent, you can only use parent methods. This is inconvenient in your situation, but it is how it works...
How would you make a VI that accepts a 'generic' and call a control property on it? Allowing that would mean that all non-control objects would ignore calling the property on them. That would be completely unreadable.
05-21-2018 09:11 AM
Try something like this.
05-21-2018 02:42 PM
Thank you paul_cardine. That's what I needed: a class name property node 🙂