Back to Devexpress

LayoutItemBase.Caption Property

aspnet-devexpress-dot-web-dot-layoutitembase.md

latest4.7 KB
Original Source

LayoutItemBase.Caption Property

Gets or sets the current layout item caption.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("")]
public virtual string Caption { get; set; }
vb
<DefaultValue("")>
Public Overridable Property Caption As String

Property Value

TypeDefaultDescription
StringString.Empty

A String value that specifies the text content of the current layout item’s caption.

|

Remarks

Note that when a single item is embedded directly to the TabbedLayoutGroup its caption is not displayed by default, because it matches the TabbedLayoutGroup caption and it does not make sense to display two identical captions. To display the item caption, wrap the editor item to the LayoutGroup container with the required caption.

Web Forms approach:

aspx
<dx:TabbedLayoutGroup ClientInstanceName="tabbedGroupPageControl" Width="100%">
    <Items>
        <dx:LayoutGroup Caption="TestGroup">
            <Items>
                ...
            </Items>
        </dx:LayoutGroup>
    </Items>
</dx:TabbedLayoutGroup>

MVC approach:

cshtml
@Html.DevExpress().FormLayout(set => {
    set.Name = "FormLayout";
    set.Items.AddTabbedGroupItem(groupSettings => {
        groupSettings.Name = "group";
        groupSettings.Items.AddGroupItem(g => {
            g.Caption = "TestGroup";
            g.Items.Add(item => {
                item.NestedExtensionType = FormLayoutNestedExtensionItemType.TextBox;
                item.Name = item.Caption = "Test Description";
                item.SetNestedContent(() => {

                Html.DevExpress().TextBox(tb => {
                    tb.Name = "Test Description";
                    tb.ShowModelErrors = true;
                }).Bind(Model.Description).Render();
            });
        });
    });
});
}).GetHtml();

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Caption 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.

asp-net-web-forms-scheduler-custom-adaptive-form-using-templates/CS/WebApplication1/DevExpress/ASPxSchedulerForms/AppointmentForm.ascx.cs#L48

csharp
void Localize() {
    appointmentFormMainLayout.FindItemOrGroupByName("itemSubject").Caption = ASPxSchedulerLocalizer.GetString(ASPxSchedulerStringId.Form_Subject);
    appointmentFormMainLayout.FindItemOrGroupByName("itemLocation").Caption = ASPxSchedulerLocalizer.GetString(ASPxSchedulerStringId.Form_Location);

asp-net-web-forms-scheduler-custom-adaptive-form-using-templates/VB/WebApplication1/DevExpress/ASPxSchedulerForms/AppointmentForm.ascx.vb#L54

vb
Private Sub Localize()
    appointmentFormMainLayout.FindItemOrGroupByName("itemSubject").Caption = ASPxSchedulerLocalizer.GetString(ASPxSchedulerStringId.Form_Subject)
    appointmentFormMainLayout.FindItemOrGroupByName("itemLocation").Caption = ASPxSchedulerLocalizer.GetString(ASPxSchedulerStringId.Form_Location)

See Also

LayoutItemBase Class

LayoutItemBase Members

DevExpress.Web Namespace