CardView.CardCaptionFormat Property

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

Namespace: DevExpress.XtraGrid.Views.Card

Assembly: DevExpress.XtraGrid.v21.2.dll

Declaration

[DefaultValue("")]
[XtraSerializableProperty]
[DXCategory("Appearance")]
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, and card field display values. Use the following placeholders to construct the card caption format:

  • {0} — Inserts the current record number.
  • {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.
  • {1[, alignment]}, {2[, alignment]}, {3[, alignment]}, etc. — Insert display text of fields referred to by their 1-based indexes in the CardView.Columns collection.

    Examples:

    • {1} — Inserts the display text of the first field (column) in the CardView.Columns collection (this column resides at position 0 in this collection).
    • {2} — Inserts the display text of the second field in the CardView.Columns collection.
    • {3, -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 the static text (“Record #”) followed by the current record number, and the display value of the ‘CategoryName’ field:

cardView1.CardCaptionFormat = "Record # {0}, {CategoryName}";

CardCaptionFormat-ex

The placeholders allow you to insert only text field values. Handle the CardView.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 CardView.GetCardCaption method to return the card caption text constructed based on the CardCaptionFormat pattern.

See Also