LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find control reference and change color

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?

0 Kudos
Message 1 of 6
(2,383 Views)

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.

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 6
(2,378 Views)

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?

0 Kudos
Message 3 of 6
(2,374 Views)

@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.

 

Message 4 of 6
(2,350 Views)

Try something like this.

"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 6
(2,305 Views)

Thank you paul_cardine. That's what I needed: a class name property node 🙂

0 Kudos
Message 6 of 6
(2,294 Views)