Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Dynamically Customize the Appearance of Card Field Captions in a Layout View

The following code shows how to dynamically change the appearance of a card field’s caption in a Layout View via the LayoutView.CustomFieldCaptionStyle event. In the example, the font of a CategoryName field’s caption is changed only in the cards that contain the “Beverages” value in this field.

The result is shown below:

LayoutView_CustomFieldCaptionStyle_ex

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

private void layoutView1_CustomFieldCaptionStyle(object sender, 
    LayoutViewFieldCaptionStyleEventArgs e) {
    if(e.Column.FieldName != "CategoryName") return;
    LayoutView view = sender as LayoutView;
    bool isBeverage = view.GetRowCellValue(e.RowHandle, e.Column).ToString() == "Beverages";
    if (isBeverage) {
        e.Appearance.FontStyleDelta = FontStyle.Bold;
    }
}