Back to Devexpress

LayoutView.CustomCardStyle Event

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

latest4.3 KB
Original Source

LayoutView.CustomCardStyle Event

Allows you to customize the appearance of a card’s caption and border.

Namespace : DevExpress.XtraGrid.Views.Layout

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[DXCategory("Behavior")]
public event LayoutViewCardStyleEventHandler CustomCardStyle
vb
<DXCategory("Behavior")>
Public Event CustomCardStyle As LayoutViewCardStyleEventHandler

Event Data

The CustomCardStyle event's data class is DevExpress.XtraGrid.Views.Layout.Events.LayoutViewCardStyleEventArgs.

Remarks

Handle the CustomCardStyle event to customize the appearance of a card’s caption and border. To change the appearance options, use the event’s Appearance parameter. The State parameter allows you to identify the card’s current state.

Note

Changing a card’s background color is not in effect in skinning paint schemes.

You can handle the CustomCardStyle event to provide different appearances for different cards. The CustomCardStyle event fires when a card is about to be painted on-screen. The currently processed card can be identified via the RowHandle parameter that specifies the card’s visual position. See Rows to learn more.

Important

Do not change cell values, modify the control’s layout, or change the control’s object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.

Example

The following example shows how to handle the LayoutView.CustomCardStyle event to change the border color for cards that contain “London” in the City field. The event handler provides different border colors for the focused and non-focused card states.

csharp
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Layout;

private void layoutView1_CustomCardStyle(object sender, DevExpress.XtraGrid.Views.Layout.Events.LayoutViewCardStyleEventArgs e) {
    LayoutView view = sender as LayoutView; 
    string city = view.GetRowCellDisplayText(e.RowHandle, colCity);
    if (city != "London") return;
    if ((e.State & GridRowCellState.Focused) != 0)
        e.Appearance.BorderColor = Color.FromArgb(192, 192, 255);
    else
        e.Appearance.BorderColor = Color.MediumOrchid;
}
vb
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Layout

Private Sub LayoutView1_CustomCardStyle(sender As Object, e As DevExpress.XtraGrid.Views.Layout.Events.LayoutViewCardStyleEventArgs) Handles LayoutView1.CustomCardStyle
    Dim view As LayoutView = CType(sender, LayoutView)
    Dim city As String = view.GetRowCellDisplayText(e.RowHandle, colCity)
    If city <> "London" Then Return
    If (e.State And GridRowCellState.Focused) <> 0 Then
        e.Appearance.BorderColor = Color.FromArgb(192, 192, 255)
    Else
        e.Appearance.BorderColor = Color.MediumOrchid
    End If
End Sub

See Also

FocusedCardCaption

CardCaption

CustomFieldCaptionStyle

CustomFieldEditingValueStyle

CustomFieldValueStyle

LayoutView Class

LayoutView Members

DevExpress.XtraGrid.Views.Layout Namespace