| |
 |
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.
C# |
using DevExpress.Utils;
using DevExpress.XtraGrid.Views.Base;
private void cardView1_CustomDrawCardField(object sender, RowCellCustomDrawEventArgs e) {
if(e.Column.FieldName != "") return;
e.Graphics.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;
}
|
VB |
Imports DevExpress.Utils
Imports DevExpress.XtraGrid.Views.Base
Private Sub CardView1_CustomDrawCardField(ByVal sender As Object, _
ByVal e As RowCellCustomDrawEventArgs) Handles CardView1.CustomDrawCardField
If Not e.Column.FieldName = "" Then Exit Sub
e.Graphics.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
End Sub
|
Is this topic helpful?
Additional Feedback
Close
|