How Do I Choose a Color in LabVIEW?

Updated Jan 12, 2023

Environment

Software

  • LabVIEW

I want to be able to select a specific color in LabVIEW in order to change the color of an object. Is there specific controls or constants available that I could use to do this? 

There are three options in LabVIEW for selecting a color value:

  • Option 1: You can use a Color Box Constant. 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.
    • The Color Box Constant is located in the Functions Palette on the Block Diagram. To add the Color Box Constant, right-click on the Block Diagram to open the Functions Palette. Then navigate to Programming»Dialog & User Interface and select the Color Box Constant.
Note: In LabVIEW versions before 8.0, this constant is located in the Functions Palette»Numeric»Additional Numeric Constants.
  • Option 2: Use a Framed Color Box. This control can be used to select a color value while the VI runs. 
    • The Framed Color Box is located in the Controls Palette on the Front Panel. To add the Framed Color Box, right-click on the Front Panel to open the Controls Palette. Then navigate to Modern»Numeric and select the Framed Color Box.
       

 

  • Option 3: You use and can assign a Numeric Control or Constant to represent a color. To assign numeric values to represent a color, complete the following steps:
    1. Depending on your application, navgate to and select a Number Control or Numeric Constant to your LabVIEW code. Note: The Numeric Constant cannot be changed by the user during execution, whereas the Numeric Control can. 
      • The Numeric Control is located in the Controls Palette on the Front Panel. To add a Numeric Control, right-click on the Front Panel to open the Controls Palette. Then navigate to Modern»Numeric and select the Numeric Control
      • The Numeric Constant is located in the Functions Palette on the Block Diagram. To add a Numeric Constant, right-click on the Block Diagram to open the Functions Palette. Then navigate to Programming»Numeric and select the Numeric Constant.
    2. Change the representation of the Numeric Control or Numeric Constant to U32 (unsigned 32-bit integer). Right-click the Numeric Control or Numeric Constant and select Representation»U32 from the shortcut menu, as shown in the following image:

  1. Make the radix of the Numeric Control or Constant visible. To do this, right-click the Numeric Control or Constant and select Visible Items»Radix from the shortcut menu.

  2. Set the radix to hexadecimal. To do this, click the small d in the Numeric Control or Constant and select Hex (hexadecimal) as shown in the following image:

  3. 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. This link to HTML Color Codes allows you to generate the hexadecimal value for any color you select.