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: Custom Draw Card Fields

The sample code below handles the CardView.CustomDrawCardField event to custom paint fields whose GridColumn.FieldName properties are not set. Such fields are considered header fields, which precede regular data fields.

A header field’s caption is painted centered. The field value is hidden.

CustomDrawCardField

using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Base;

private void cardView1_CustomDrawCardField(object sender, RowCellCustomDrawEventArgs e) {
   if(e.Column.FieldName != "") return;
   e.Cache.FillRectangle(e.Cache.GetSolidBrush(SystemColors.Control), e.Bounds);
   e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
   e.Appearance.Font = e.Cache.GetFont(e.Appearance.Font, FontStyle.Bold);
   e.Appearance.DrawString(e.Cache, e.Column.Caption, e.Bounds);
   e.Handled = true;
}