Programmatically Change the Color of a Front Panel Object

Updated May 3, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

  • How do I change color values of objects in the LabVIEW environment?
  • Is there a way to programmatically assign colors using a control or some numerical value with a Property Node?

Solution

Choosing a Color

There are three ways to select a color value for setting a color programmatically: 
  • You can place a Color Box Constant, located in the Functions»Programming»Dialog and User Interface palette, on the block diagram.



    This constant can be used to change the color of a Front Panel object while the VI executes, but the color selection cannot be changed by the user during execution.  

    Note: In LabVIEW versions before 8.0, this constant is located in the Functions»Numeric»Additional Numeric Constants palette.

  • You can place a Framed Color Box, located in the Controls»Numeric palette, on the Front Panel. This control can be used to select a color value while the VI runs. 


  • You can assign numeric values to represent a color. 
    To assign numeric values to represent a color, complete the following steps:

    1. Place a Numeric Control, located in the Controls»Numeric palette, on the Front Panel. Alternatively, you can place a Numeric Constant, located in the Functions»Numericpalette, on the block diagram.
    2. Similarly to the options above, the numeric constant cannot be changed by the user during execution, whereas the numeric control can. 

    • Change the representation of the control or constant to U32 (unsigned 32-bit integer). Right-click the control and select Representation»U32 from the shortcut menu, as shown in the following image:


    • Show the radix for the control or constant. Right-click the control or constant and select Visible Items»Radix from the shortcut menu.
    • Set the radix to hexadecimal. Use the Operating tool to click the small "d" in the control or constant and click Hex (hexadecimal) as shown in the following image:


    • Enter a hexadecimal value for the color in the form RRGGBB. For example, a value of FF0000 represents the color red, a value of 00FF00 represents green, and a value of 0000FF represents blue.  An external link of more color options can be seen in the related links section below.

    Programmatically Changing to a Color

    Once a control or constant has been created for selecting the color value, you can connect this color to a Property Node for setting the color of a Front Panel object, by completing the following steps: 
    1. Right-click the Front Panel object you would like to programmatically change the color of, and click Create»Property Node.  
    2. Select the property for the color setting you want to modify.
    3. Place the Property Node on your block diagram, and wire the input to the color control or constant you created before.
    The following images show the different methodologies you can use to programmatically change the background color of a String Control:
    • Color Box Constant:
    • Color Box Control:
    • Numeric Control:

     

    WAS THIS ARTICLE HELPFUL?

    Not Helpful