Back to Devexpress

LayoutView.CustomCardCaptionImage Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-layout-dot-layoutview-61819b1f.md

latest5.0 KB
Original Source

LayoutView.CustomCardCaptionImage Event

Allws you to display custom images within card captions.

Namespace : DevExpress.XtraGrid.Views.Layout

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Appearance")]
public event LayoutViewCardCaptionImageEventHandler CustomCardCaptionImage
vb
<DXCategory("Appearance")>
Public Event CustomCardCaptionImage As LayoutViewCardCaptionImageEventHandler

Event Data

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

PropertyDescription
CaptionImageLocationGets or sets the relative position of an image within a card’s caption.
CaptionImageVisibleGets or sets whether the image in a card’s caption is visible.
ImageGets or sets the image to be displayed within an element. Inherited from CardCaptionImageEventArgs.
ImageIndexGets or sets the index of the image to be displayed within a visual element. Inherited from CardCaptionImageEventArgs.
ImageListGets or sets the source collection of images. Inherited from CardCaptionImageEventArgs.
RowHandleGets 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.

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

csharp
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;
}
vb
Private Sub layoutView_CustomCardCaptionImage(ByVal sender As Object, ByVal e As LayoutViewCardCaptionImageEventArgs)
    ' Specifies a custom collection with SVG icons.
    e.ImageList = svgImageCollection1
    ' Displays an image within the card's caption based on a condition.
    e.ImageIndex = If(CStr((TryCast(sender, LayoutView)).GetRowCellValue(e.RowHandle, "Title")).Contains("President"), 1, 0)
    ' Specifies the image location (before text).
    e.CaptionImageLocation = GroupElementLocation.BeforeText
End Sub

The following image shows the result:

See Also

Images

LayoutView Class

LayoutView Members

DevExpress.XtraGrid.Views.Layout Namespace