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: Create a custom painter to override the way footers are painted

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.

CustomPaintHelper - Footer

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);