Back to Devexpress

LabelComponent Class

windowsforms-devexpress-dot-xtragauges-dot-win-dot-base-f6b77bd1.md

latest5.1 KB
Original Source

LabelComponent Class

Represents a label for a gauge.

Namespace : DevExpress.XtraGauges.Win.Base

Assembly : DevExpress.XtraGauges.v25.2.Win.dll

NuGet Package : DevExpress.Win.Gauges

Declaration

csharp
public class LabelComponent :
    Label,
    ISupportInitialize,
    IBindableComponent,
    IComponent,
    IDisposable,
    ICustomizationFrameClient,
    ISupportCustomizeAction,
    ISupportVisualDesigning,
    ISupportPropertyGridWrapper,
    ISupportAssign<LabelComponent>
vb
Public Class LabelComponent
    Inherits Label
    Implements ISupportInitialize,
               IBindableComponent,
               IComponent,
               IDisposable,
               ICustomizationFrameClient,
               ISupportCustomizeAction,
               ISupportVisualDesigning,
               ISupportPropertyGridWrapper,
               ISupportAssign(Of LabelComponent)

The following members return LabelComponent objects:

Remarks

A label allows custom text to be displayed within any gauge. Use the inherited Label.Text property to specify the text. Labels support HTML formatting, with which you can use HTML tags to format portions of text in a specific manner. See the Label.Text property to learn more.

In code, you can add labels to a gauge via the BaseGaugeWin.Labels collection.

Labels represented by the LabelComponent component do not support the automatic display of a scale’s value in circular and linear gauges. To display a scale’s value as a label in these gauges, probably along with custom text, you need to add a label to the scale’s Labels collection (ArcScale.Labels or LinearScale.Labels). This scale label provides the FormatString property that supports a special placeholder for displaying the scale’s current value.

See Scales to learn more.

Example

The following code shows how to add a static label (LabelComponent) to a circular gauge. The label displays custom text and formats its appearance using HTML tags.

The result is shown below:

csharp
using DevExpress.XtraGauges.Win.Base;
using DevExpress.XtraGauges.Core.Drawing;

circularGauge1.BeginUpdate();
LabelComponent label = new LabelComponent("myLabel");
label.AppearanceText.TextBrush = new SolidBrushObject(Color.Black);
label.Position = new DevExpress.XtraGauges.Core.Base.PointF2D(125, 210);
label.ZOrder = -10000;
label.AllowHTMLString = true;
label.Text = "<color=RED>MPH</color> <b>/</b> <color=BLUE>KM/H</color>";
circularGauge1.Labels.Add(label);
circularGauge1.EndUpdate();
vb
Imports DevExpress.XtraGauges.Win.Base
Imports DevExpress.XtraGauges.Core.Drawing

circularGauge1.BeginUpdate()
Dim label As LabelComponent = New LabelComponent("myLabel")
label.AppearanceText.TextBrush = New SolidBrushObject(Color.Black)
label.Position = New DevExpress.XtraGauges.Core.Base.PointF2D(125, 210)
label.ZOrder = -10000
label.AllowHTMLString = True
label.Text = "<color=RED>MPH</color> <b>/</b> <color=BLUE>KM/H</color>"
circularGauge1.Labels.Add(label)
circularGauge1.EndUpdate()

Inheritance

Object BaseObject DevExpress.XtraGauges.Core.Base.BaseElement<DevExpress.XtraGauges.Core.Primitive.IRenderableElement> DevExpress.XtraGauges.Core.Base.BaseLeaf<DevExpress.XtraGauges.Core.Primitive.IRenderableElement> BaseLeafPrimitive DevExpress.XtraGauges.Core.Model.BaseScaleIndependentComponent<DevExpress.XtraGauges.Core.Model.BaseLabelProvider> DevExpress.XtraGauges.Core.Model.ScaleIndependentLayerComponent<DevExpress.XtraGauges.Core.Model.BaseLabelProvider> Label LabelComponent

See Also

LabelComponent Members

ArcScale.Labels

LinearScale.Labels

DevExpress.XtraGauges.Win.Base Namespace