Skip to main content
A newer version of this page is available. .

LabelControl.Text Property

Gets or sets the label’s text.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v19.1.dll

Declaration

[DXCategory("Appearance")]
[SettingsBindable(true)]
[SmartTagProperty("Text", "", SmartTagActionType.RefreshBoundsAfterExecute)]
public override string Text { get; set; }

Property Value

Type Description
String

A String value that specifies the label’s text.

Remarks

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

Note

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

Example

The following example shows how to format a LabelControl‘s text using HTML tags. HTML formatting is enabled via the LabelControl.AllowHtmlString property. To respond to an end-user clicking the 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;

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the Text property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also