windowsforms-5663-controls-and-libraries-tree-list-examples-appearance-how-to-create-a-custom-painter-to-override-the-way-footers-are-painted.md
The code below creates a simple paint helper, deriving it from the standard TreeListPaintHelper class. The DrawFooterBackGround method is overridden to custom paint the summary footer.
The image below shows the Tree List control before and after the code has been executed.
using DevExpress.Utils;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Painter;
using System.Drawing.Drawing2D;
// ...
public class SimplePaintHelper : TreeListPaintHelper {
internal SimplePaintHelper(ImageList il_Indicator) : base() { }
public override void DrawFooterBackGround(CustomDrawEventArgs e) {
LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, Color.FromArgb(244, 210, 227), Color.FromArgb(207, 196, 230), LinearGradientMode.Vertical);
using (brush) {
e.Cache.FillRectangle(brush, e.Bounds);
}
}
}
//...
// Use the painter:
treeList1.Painter.DefaultPaintHelper = new SimplePaintHelper(treeList1.Painter.IndicatorImages);
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)
Using Brush
e.Cache.FillRectangle(Brush, e.Bounds)
End Using
End Sub
End Class
'...
' Use the painter:
TreeList1.Painter.DefaultPaintHelper = New SimplePaintHelper(TreeList1.Painter.IndicatorImages)