本示例展示了如何通过 GridView.CustomDrawFooterCell 事件,执行 脚注单元格 的自定义绘制。
以浮雕效果绘制脚注单元格。
C# | 复制代码 |
---|---|
using System.Drawing.Drawing2D; using DevExpress.XtraGrid.Views.Grid; private void gridView1_CustomDrawFooterCell(object sender, FooterCellCustomDrawEventArgs e) { int dx = e.Bounds.Height; Brush brush = e.Cache.GetGradientBrush(e.Bounds, Color.Wheat, Color.FloralWhite, LinearGradientMode.Vertical); Rectangle r = e.Bounds; //Create a raised effect for a cell ControlPaint.DrawBorder3D(e.Graphics, r, Border3DStyle.RaisedInner); //Fill the inner region of the cell r.Inflate(-1, -1); e.Graphics.FillRectangle(brush, r); //Draw a summary value r.Inflate(-2, 0); e.Appearance.DrawString(e.Cache, e.Info.DisplayText, r); //Prevent default drawing of the cell e.Handled = true; } |
Visual Basic | 复制代码 |
---|---|
Imports System.Drawing.Drawing2D Imports DevExpress.XtraGrid.Views.Grid Private Sub GridView1_CustomDrawFooterCell(ByVal sender As Object, _ ByVal e As FooterCellCustomDrawEventArgs) Handles GridView1.CustomDrawFooterCell Dim dx As Integer = e.Bounds.Height Dim brush As Brush = e.Cache.GetGradientBrush(e.Bounds, Color.Wheat, Color.FloralWhite, _ LinearGradientMode.Vertical) Dim r As Rectangle = e.Bounds 'Create a raised or depressed effect for a cell depending on the band index ControlPaint.DrawBorder3D(e.Graphics, r, Border3DStyle.RaisedInner) 'Fill the inner region of the cell r.Inflate(-1, -1) e.Graphics.FillRectangle(brush, r) 'Draw a summary value r.Inflate(-2, 0) e.Appearance.DrawString(e.Cache, e.Info.DisplayText, r) 'Prevent default drawing of the cell e.Handled = True End Sub |