下面的代码创建了一个简单的绘制帮助器,它派生于标准的 TreeListPaintHelper 类。 DrawFooterBackGround 方法被重写,以便实现自定义绘制 汇总脚注

下面的插图展示了在运行代码之前和之后的 XtraTreeList 控件。

C#CopyCode image复制代码
using DevExpress.Utils;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Painter;
using System.Drawing.Drawing2D;
// ...
public class SimplePaintHelper : TreeListPaintHelper {
   internal SimplePaintHelper(ImageList il_Indicator) : base(il_Indicator) {}
   public override void DrawFooterBackGround(CustomDrawEventArgs e) {
      LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, 
Color.FromArgb(244, 210, 227), Color.FromArgb(207, 196, 230), 
LinearGradientMode.Vertical);
      e.Graphics.FillRectangle(brush, e.Bounds);
   }
}

//...
// Use the painter:
treeList1.Painter.DefaultPaintHelper = new SimplePaintHelper(treeList1.Painter.IndicatorImages);
Visual BasicCopyCode image复制代码
Imports DevExpress.Utils
Imports DevExpress.XtraTreeList
Imports DevExpress.XtraTreeList.Painter
Imports System.Drawing.Drawing2D
' ...
Public Class SimplePaintHelper
   Inherits TreeListPaintHelper

   Friend Sub New(ByVal il_Indicator As ImageList)
      MyBase.New(il_Indicator)
   End Sub

   Public Overrides Sub DrawFooterBackGround(ByVal e As CustomDrawEventArgs)
      Dim Brush As New LinearGradientBrush(e.Bounds, Color.FromArgb(244, 210, 227), 
Color.FromArgb(207, 196, 230), LinearGradientMode.Vertical)
      e.Graphics.FillRectangle(Brush, e.Bounds)
   End Sub
End Class

'...
' Use the painter:
TreeList1.Painter.DefaultPaintHelper = New SimplePaintHelper(TreeList1.Painter.IndicatorImages)