windowsforms-devexpress-dot-xtragrid-dot-views-dot-card-dot-cardview-31aaed35.md
Enables custom images to be shown in card captions.
Namespace : DevExpress.XtraGrid.Views.Card
Assembly : DevExpress.XtraGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation
[DXCategory("Appearance")]
public event CardCaptionImageEventHandler CustomCardCaptionImage
<DXCategory("Appearance")>
Public Event CustomCardCaptionImage As CardCaptionImageEventHandler
The CustomCardCaptionImage event's data class is CardCaptionImageEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Image | Gets or sets the image to be displayed within an element. |
| ImageIndex | Gets or sets the index of the image to be displayed within a visual element. |
| ImageList | Gets or sets the source collection of images. |
| RowHandle | Gets the handle of the processed card. |
The CustomCardCaptionImage event fires for each card within a Card View and allows you to specify images for the captions of individual cards. The card referenced is identified by the event’s CardCaptionImageEventArgs.RowHandle parameter.
Images can be specified in one of two ways:
Note that the CardCaptionImageEventArgs.Image property takes priority over the CardCaptionImageEventArgs.ImageIndex property.
In the following code snippet from the GridMainDemo, the CardView.CustomCardCaptionImage event is handled to display custom images in card captions. First, an underlying data object (VehiclesData.Model) corresponding to the currently processed card is obtained using the ColumnView.GetRow method. The image to display in the card caption is retrieved from this object and assigned to the event’s Image parameter. Please refer to the GridMainDemo for a complete example.
private void cardView1_CustomCardCaptionImage(object sender, DevExpress.XtraGrid.Views.Card.CardCaptionImageEventArgs e) {
VehiclesData.Model model = cardView1.GetRow(e.RowHandle) as VehiclesData.Model;
e.Image = model.GetSmallTrademarkImage();
}
Private Sub cardView1_CustomCardCaptionImage(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Card.CardCaptionImageEventArgs) Handles cardView1.CustomCardCaptionImage
Dim model As VehiclesData.Model = TryCast(cardView1.GetRow(e.RowHandle), VehiclesData.Model)
e.Image = model.GetSmallTrademarkImage()
End Sub
See Also