Back to Devexpress

BaseLayoutItem.Text Property

windowsforms-devexpress-dot-xtralayout-dot-baselayoutitem-a9ac8868.md

latest10.9 KB
Original Source

BaseLayoutItem.Text Property

Gets or sets the caption of this layout item. If the Text property is null (Nothing in VB.NET) or String.Empty, this property returns the item name.

Namespace : DevExpress.XtraLayout

Assembly : DevExpress.XtraLayout.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[Bindable(true)]
[DXCategory("Text")]
[XtraSerializableProperty]
[XtraSerializablePropertyId(400)]
public virtual string Text { get; set; }
vb
<XtraSerializableProperty>
<XtraSerializablePropertyId(400)>
<Bindable(True)>
<DXCategory("Text")>
Public Overridable Property Text As String

Property Value

TypeDescription
String

A string that is 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.

Tip

Do not set the Text property to null or String.Empty. Doing so does not hide the item caption, the item shows its name instead. As a workaround, you can set the Text property to " " (space character).

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”:

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.

csharp
layoutControlItem1.Text = "<size=14>Size = 14 <u>Underline</u> 
 <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;
vb
LayoutControlItem1.Text = "<size=14>Size = 14 <u>Underline</u> 
 <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.

xaf-how-to-show-the-number-of-nested-list-views-items-in-tab-captions/CS/EFCore/TabCountEF/TabCountEF.Win/Controllers/ContactDetailViewWinController.cs#L72

csharp
int count = View.CollectionSource.GetCount();
layoutGroup.Text = DetailViewControllerHelper.ClearItemCountInTabCaption(layoutGroup.Text);
if(count > 0) {

winforms-richedit-layout-api/CS/Form1.cs#L51

csharp
#endregion #GetVisiblePages
    lblPageInfo.Text = s;
}

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/Form1.cs#L212

csharp
string exampleCode = codeEditor.ShowExample(oldExample, newExample);
codeExampleNameLbl.Text = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example";
CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();

winforms-spreadsheet-pivot-table-api/CS/SpreadsheetPivotTableExamples/Form1.cs#L197

csharp
string exampleCode = codeEditor.ShowExample(oldExample, newExample);
codeExampleNameLbl.Text = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) + " example";
CodeEvaluationEventArgs args = new CodeEvaluationEventArgs();

winforms-scheduler-custom-recurrence-form/CS/CustomRecurrenceFormDescendantSample/MyAppointmentRecurrenceForm.cs#L23

csharp
base.grpRecurrencePattern.Text =
    "You can edit only daily recurring appointments";

winforms-richedit-layout-api/VB/Form1.vb#L41

vb
' #End Region ' #GetVisiblePages
            lblPageInfo.Text = s
        End Sub

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/Form1.vb#L206

vb
Dim exampleCode As String = codeEditor.ShowExample(oldExample, newExample)
codeExampleNameLbl.Text = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) & " example"
Dim args As New CodeEvaluationEventArgs()

winforms-spreadsheet-pivot-table-api/VB/SpreadsheetPivotTableExamples/Form1.vb#L189

vb
Dim exampleCode As String = codeEditor.ShowExample(oldExample, newExample)
codeExampleNameLbl.Text = CodeExampleDemoUtils.ConvertStringToMoreHumanReadableForm(newExample.RegionName) & " example"
Dim args As New CodeEvaluationEventArgs()

winforms-scheduler-custom-recurrence-form/VB/CustomRecurrenceFormDescendantSample/MyAppointmentRecurrenceForm.vb#L21

vb
grpRecurrencePattern.Text = "You can edit only daily recurring appointments"
Text = "Appointment Recurrence: Modified Form"

winforms-dashboard-custom-properties/VB/WinForms-Dashboard-Custom-Properties/Modules/DashboardDescriptionModule.vb#L48

vb
memoEditLayoutItem.TextLocation = Locations.Top
memoEditLayoutItem.Text = "Text:"
Dim memoEdit As New MemoEdit()

See Also

TextLocation

TextSize

TextToControlDistance

TextVisible

LayoutControlItem.TextAlignMode

OptionsItemTextGroup.TextAlignMode

OptionsItemText.TextAlignMode

AllowHtmlStringInCaption

GetDisplayText()

How to: Provide accessible names for embedded controls

HTML-inspired Text Formatting

BaseLayoutItem Class

BaseLayoutItem Members

DevExpress.XtraLayout Namespace