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

LayoutView.CustomCardCaptionImage Event

Allws you to display custom images within card captions.

Namespace: DevExpress.XtraGrid.Views.Layout

Assembly: DevExpress.XtraGrid.v22.1.dll

NuGet Package: DevExpress.Win.Grid

Declaration

[DXCategory("Appearance")]
public event LayoutViewCardCaptionImageEventHandler CustomCardCaptionImage

Event Data

The CustomCardCaptionImage event's data class is LayoutViewCardCaptionImageEventArgs. The following properties provide information specific to this event:

Property Description
CaptionImageLocation Gets or sets the relative position of an image within a card’s caption.
CaptionImageVisible Gets or sets whether the image in a card’s caption is visible.
Image Gets or sets the image to be displayed within an element. Inherited from CardCaptionImageEventArgs.
ImageIndex Gets or sets the index of the image to be displayed within a visual element. Inherited from CardCaptionImageEventArgs.
ImageList Gets or sets the source collection of images. Inherited from CardCaptionImageEventArgs.
RowHandle Gets the handle of the processed card. Inherited from CardCaptionImageEventArgs.

Remarks

Handle the CustomCardCaptionImage event to display custom images within card captions. The event fires for each card. Use the event’s e.RowHandle parameter to identify the card currently being processed.

Images can be specified in one of two ways:

  • Use the event’s e.Image parameter.
  • Use the event’s e.ImageIndex parameter that specifies the image by its index in the image collection.

    By default, the image is obtained from the View’s Images collection. Use the event’s e.ImageList parameter to specify a custom image collection.

The e.Image property takes priority over the e.ImageIndex property.

private void layoutView_CustomCardCaptionImage(object sender, LayoutViewCardCaptionImageEventArgs e) {
    // Specifies a custom collection with SVG icons.
    e.ImageList = svgImageCollection1;
    // Displays an image within the card's caption based on a condition.
    e.ImageIndex = ((string)(sender as LayoutView).GetRowCellValue(e.RowHandle, "Title")).Contains("President") ? 1: 0;
    // Specifies the image location (before text).
    e.CaptionImageLocation = GroupElementLocation.BeforeText;
}

The following image shows the result:

Display Custom Images within Card Captions - WinForms Grid, Layout View

See Also