windowsforms-devexpress-dot-xtragrid-dot-views-dot-layout-dot-layoutview-61819b1f.md
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
[DXCategory("Appearance")]
public event LayoutViewCardCaptionImageEventHandler CustomCardCaptionImage
<DXCategory("Appearance")>
Public Event CustomCardCaptionImage As LayoutViewCardCaptionImageEventHandler
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. |
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:
e.Image parameter.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.
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;
}
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