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

BaseLayoutItem.Text Property

Gets or sets the text associated with the layout item.

Namespace: DevExpress.XtraLayout

Assembly: DevExpress.XtraLayout.v19.2.dll

Declaration

[XtraSerializableProperty]
[Bindable(true)]
[DXCategory("Text")]
public virtual string Text { get; set; }

Property Value

Type Description
String

A string that specifies the layout item’s text.

Remarks

This property specifies the text that is associated with the layout item. For LayoutControlItem items this text is displayed next to the item’s control. For LayoutControlGroup items the Text string represents the group’s caption.

To hide or display the text, use the BaseLayoutItem.TextVisible Boolean property. For LayoutControlItem items, the text region’s size can be modified with the BaseLayoutItem.TextSize property. For instance, you can use this property to allocate more space to the text region.

A LayoutControlItem‘s text can be displayed at the left, top, right or bottom edge of the item’s control. To change the text position, use the BaseLayoutItem.TextLocation property.

The Text property allows you to specify a hotkey (ALT+Character) a user can press to focus the layout item’s control. Prefix the target Character with the ampersand symbol (‘&’). This character is underscored when the ALT key is pressed at runtime. For the following layout item, the Text property is set to “Contact &Name”:

ItemLabel_Shortcut

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

To get the plain display text (without HTML tags and the ampersand symbols, if any), use the BaseLayoutItem.GetDisplayText method.

Example

The following example shows how to format the BaseLayoutItem.Text using HTML tags. HTML formatting is enabled via the LayoutControlItem.AllowHtmlStringInCaption property.

layoutItem_HTML_formatting

layoutControlItem1.Text = "<size=14>Size = 14 <u>Underline</u> <br> <size=11>Size = 11 <color=255, 0, 0>Red";
layoutControlItem1.AllowHtmlStringInCaption = true;
// Increase the control's height
layoutControlItem1.SizeConstraintsType = DevExpress.XtraLayout.SizeConstraintsType.Custom;
layoutControlItem1.MinSize = new Size(layoutControlItem1.MinSize.Width, 50);
layoutControlItem1.AppearanceItemCaption.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;

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