Back to Devexpress

Label.Text Property

corelibraries-devexpress-dot-xtragauges-dot-core-dot-model-dot-label-d8982eef.md

latest3.4 KB
Original Source

Label.Text Property

Gets or sets the label’s text.

Namespace : DevExpress.XtraGauges.Core.Model

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

NuGet Package : DevExpress.Gauges.Core

Declaration

csharp
[DefaultValue("Text")]
public string Text { get; set; }
vb
<DefaultValue("Text")>
Public Property Text As String

Property Value

TypeDefaultDescription
String"Text"

A string that specifies the label’s text.

|

Remarks

The display text is formed according the Label.FormatString property. By default, it’s set to {0}, where the {0} placeholder specifies the value of the Text property. So, by default, the value of the Text property is displayed as is.

A label’s text can be formatted using HTML tags. For instance, you can mark specific portions of text bold or italic, change the font and font color, etc. To enable HTML formatting, set the Label.AllowHTMLString property to true. See HTML Text Formatting, 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()

See Also

FormatString

AllowHTMLString

HTML-inspired Text Formatting

Label Class

Label Members

DevExpress.XtraGauges.Core.Model Namespace