Version

Add Labels to a Gauge

Labels are numeric or text values that are associated with the values of the scale. You need to add labels to a gauge in order to represent values on the scale.

Note
Note

This topic assumes that you already created a Radial gauge with a scale and tick marks. For information on how to do this, see Add Tick Marks to a Scale on a Gauge.

The next step after adding labels to your gauge is to Add a Needle Marker to a Gauge.

You can add labels to your scale:

When you save and run your application after completing the following steps, your form should look similar to the form below.

WinGauge with labels.

To add labels to your scales using the Gauge Designer:

  1. In the Gauge Explorer, expand Scale.

  2. Select Labels.

  3. In the Properties panel, click the Labels Layout tab. In the Orientation pane, set the following properties:

    • Extent — 65

    • Orientation — Horizontal

  1. In the Formatting pane of the Labels Layout tab, set the following properties:

    • Frequency — 20.00

    • Span Max — 18

  1. Click the Labels Appearance tab. In the Brush pane, set the following properties:

    • Type — Solid

    • Color — White

  1. In the Font pane of the Labels Appearance tab, set the following properties:

    • Font — Arial

    • Size — 14

    • Type — Pixel

    • Style — Bold

  1. You can see the labels applied to your Radial gauge in the interactive preview area.

To add labels to your scales at design time:

  1. In the Scales collection editor, with a Scale selected, expand the Labels property.

  2. Click the BrushElement property. Then, from the drop-down list, select Solid Fill.

  3. Expand the BrushElement property, and set the Color property to White.

  4. Set the Extent property to 65.

  5. Set the Frequency property to 20\.

  6. Expand the Font property, and set the following properties:

    • Name — Arial

    • Size — 14

    • Unit — Pixel

    • Bold — True

To add labels to your scales at run time:

  1. Add the following steps to the load event.

  2. Create an instance of the class:

In Visual Basic:

Dim mySolidFillBrushElement1 As New SolidFillBrushElement()

In C#:

SolidFillBrushElement mySolidFillBrushElement1 = new SolidFillBrushElement();
  1. Set the following color properties:

    • Type — Solid

    • Color — White

In Visual Basic:

mySolidFillBrushElement1.Color = System.Drawing.Color.White
myScale.Labels.BrushElement = mySolidFillBrushElement1

In C#:

mySolidFillBrushElement1.Color = System.Drawing.Color.White;
myScale.Labels.BrushElement = mySolidFillBrushElement1;
  1. Set the following properties:

    • Font — Arial

    • Font Size — 14

    • Font Type — Pixel

    • Font Style — Bold

    • Extent — 65

    • Frequency — 20

    • Orientation — Horizontal

    • SpanMaximum — 18

In Visual Basic:

myScale.Labels.Extent = 65
myScale.Labels.Font = _
  New System.Drawing.Font("Arial", 14.0F, _
  System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel)
myScale.Labels.Frequency = 20
myScale.Labels.Orientation = _
  Infragistics.UltraGauge.Resources.RadialLabelOrientation.Horizontal
myScale.Labels.SpanMaximum = 18

In C#:

myScale.Labels.Extent = 65;
myScale.Labels.Font =
  new System.Drawing.Font("Arial", 14F,
  System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel);
myScale.Labels.Frequency = 20;
myScale.Labels.Orientation =
  Infragistics.UltraGauge.Resources.RadialLabelOrientation.Horizontal;
myScale.Labels.SpanMaximum = 18;