Change label color by script

Contents[Hide]

1. Overview

This article shows you how to change a label or any component background color by script. For example, you want to change the color of the background of a component when it is clicked or hovered over.

2. Setting Up

For example, you have a label in the dashboard.

 

Sample Label
Sample Label

It has the following Look properties with the background color of #F2F2F2.

Initial Look Properties for Label
Initial Look Properties for Label

3. Adding the script

If you want to change the label when an action is performed, add the following script in Actions > Click:

label1.background = new dundas.controls.SolidColorBrush(new dundas.controls.Color(0xFFAAAA));

Scripting for Label
Scripting for Label

Once this is added, you could try to view it in the dashboard and click on the label to change the color.

Label After Click
Label After Click

Look Properties for Label After Click
Look Properties for Label After Click

4. See also

Dundas Data Visualization, Inc.
500-250 Ferrand Drive
Toronto, ON, Canada
M3C 3G8

North America: 1.800.463.1492
International: 1.416.467.5100

Dundas Support Hours: 7am-6pm, ET, Mon-Fri