Back to Devexpress

Label.AllowHTMLString Property

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

latest3.5 KB
Original Source

Label.AllowHTMLString Property

Gets or sets whether HTML tags can be used to format the Label.Text.

Namespace : DevExpress.XtraGauges.Core.Model

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

NuGet Package : DevExpress.Gauges.Core

Declaration

csharp
[DefaultValue(false)]
public bool AllowHTMLString { get; set; }
vb
<DefaultValue(False)>
Public Property AllowHTMLString As Boolean

Property Value

TypeDefaultDescription
Booleanfalse

true if HTML formatting is supported for the label’s text; otherwise, false.

|

Remarks

If the AllowHTMLString property is set to true , you can use HTML tags to format the Label.Text. See HTML Text Formatting, to learn about the supported HTML tags.

Example

The following example shows how to create a scale value label for a linear gauge. The label will indicate the scale’s current value, formatted in a specific manner.

In the example, the label is added via the LinearScale.Labels collection. The result is shown below:

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

linearScaleComponent1.BeginUpdate();
// Create a label.
ScaleLabel label = new ScaleLabel();
label.Name = "MyLabel";
label.Position = new DevExpress.XtraGauges.Core.Base.PointF2D(160, 125);
label.AppearanceText.TextBrush = new SolidBrushObject("Color:Black");
// Enable HTML formattings and format the label's text via the FormatString property.
label.AllowHTMLString = true;
label.Text = "";
label.FormatString = "T=<b>{1:F0}°</b>";
// Add the label to the scale.
linearScaleComponent1.Labels.Add(label);
linearScaleComponent1.EndUpdate();
vb
Imports DevExpress.XtraGauges.Win.Base
Imports DevExpress.XtraGauges.Core.Drawing
Imports DevExpress.XtraGauges.Core.Model

linearScaleComponent1.BeginUpdate()
' Create a label.
Dim label As ScaleLabel = New ScaleLabel()
label.Name = "MyLabel"
label.Position = New DevExpress.XtraGauges.Core.Base.PointF2D(160, 125)
label.AppearanceText.TextBrush = New SolidBrushObject("Color:Black")
' Enable HTML formattings and format the label's text via the FormatString property.
label.AllowHTMLString = True
label.Text = ""
label.FormatString = "T=<b>{1:F0}°</b>"
' Add the label to the scale.
linearScaleComponent1.Labels.Add(label)
linearScaleComponent1.EndUpdate()

See Also

Text

HTML-inspired Text Formatting

Label Class

Label Members

DevExpress.XtraGauges.Core.Model Namespace