Skip to main content

LayoutView.CardCaptionFormat Property

Gets or sets the format string for text in card captions.

Namespace: DevExpress.XtraGrid.Views.Layout

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DefaultValue("")]
[DXCategory("CardOptions")]
[XtraSerializableProperty]
public string CardCaptionFormat { get; set; }

Property Value

Type Default Description
String String.Empty

A string that specifies the card caption text pattern.

Remarks

The CardCaptionFormat property allows you to specify the pattern used to construct text in card captions. You can display static text, the current record number, the total record count, and card field display values. Use the following placeholders to construct the card caption format:

  • {0} — Inserts the current record number.
  • {1} — Inserts the total record count (LayoutView.RecordCount).
  • {FieldName[, alignment]} — Inserts the specified field’s display text. The optional alignment setting is a signed integer that specifies the preferred width of the resulting string. See the following link for more information: Alignment Component.

    Examples:

    • {ModelPrice} — Returns the display text of the ‘ModelPrice’ field.
    • {CategoryID, 10} — Returns the display text of the ‘CategoryID’ row (field) with a 10-character requirement. If the length of the field’s display text is less than 10 characters, the resulting string is padded with leading spaces to meet this requirement.
  • {2[, alignment]}, {3[, alignment]}, {4[, alignment]}, etc. — Insert display text of fields referred to by their 2-based indexes in the LayoutView.Columns collection.

    Examples:

    • {2} — Inserts the display text of the first field (column) in the LayoutView.Columns collection (this column resides at position 0 in this collection).
    • {3} — Inserts the display text of the second field in the LayoutView.Columns collection.
    • {4, -10} — Returns the display text of the third field with a 10-character requirement. If the length of the field’s display text is less than 10 characters, the resulting string is padded with trailing spaces to meet this requirement.

In the following example, the card caption format displays a record index, the total record number, and the display value of the ‘CategoryName’ field:

layoutView1.CardCaptionFormat = "Record {0} of {1} - {CategoryName}";

LayoutView CardCaptionFormat

The placeholders allow you to insert only text field values. Handle the LayoutView.CustomCardCaptionImage event to display images in card captions.

A field’s DisplayFormat property and ColumnView.CustomColumnDisplayText event allow you to specify field display text in card captions.

Use the LayoutView.GetCardCaption method to return the card caption text constructed based on the CardCaptionFormat pattern.

See Also