Back to Devexpress

CardView.CustomCardCaptionImage Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-card-dot-cardview-31aaed35.md

latest4.8 KB
Original Source

CardView.CustomCardCaptionImage Event

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

Declaration

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

Event Data

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

PropertyDescription
ImageGets or sets the image to be displayed within an element.
ImageIndexGets or sets the index of the image to be displayed within a visual element.
ImageListGets or sets the source collection of images.
RowHandleGets the handle of the processed card.

Remarks

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.

Example

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.

csharp
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();
}
vb
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

Images

CardView Class

CardView Members

DevExpress.XtraGrid.Views.Card Namespace