Skip to main content

LabelControl.AllowHtmlString Property

Gets or sets whether HTML formatting is allowed.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DefaultValue(false)]
[DXCategory("Appearance")]
public virtual bool AllowHtmlString { get; set; }

Property Value

Type Default Description
Boolean false

true if HTML formatting is allowed; otherwise, false.

Remarks

If the AllowHtmlString property is set to true, you can use HTML tags to format the LabelControl.Text. For detailed information, see HTML Text Formatting.

Note

Long words are not wrapped if the AllowHtmlString option is enabled.

Example

The following example shows how to format a LabelControl‘s text using HTML tags. HTML formatting is enabled with the LabelControl.AllowHtmlString property. To respond to end-user clicks on a hyperlink, the LabelControl.HyperlinkClick event is handled. The image below shows the result:

label_HTML_formatting

labelControl1.Text = "<size=14>Size = 14<br>" +
                     "<b>Bold</b> <i>Italic</i> <u>Underline</u><br>" + 
                     "<size=11>Size = 11<br>" + 
                     "<color=255, 0, 0>Sample Text</color></size>" +
                     "<href=www.devexpress.com>Hyperlink</href>";
labelControl1.AllowHtmlString = true;
labelControl1.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
labelControl1.Appearance.Options.UseTextOptions = true;
labelControl1.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical;
labelControl1.HyperlinkClick += LabelControl1_HyperlinkClick;

private void labelControl1_HyperlinkClick(object sender, DevExpress.Utils.HyperlinkClickEventArgs e) {
    System.Diagnostics.Process.Start(e.Link);
}
See Also