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 Custom Paint the Tree List Background

The following example demonstrates how to handle the tree list’s OnCustomDrawBackgroundCell event, used to manually paint the tree list background:

Delphi
//...
var
  ABitmap: TBitmap;
//...
procedure <Form>.FormCreate(Sender: TObject);
begin
  ABitmap := TBitmap.Create;
  ABitmap.LoadFromFile('E:\EARTH16.BMP');
end;
//...
procedure <Form>.<TreeList>CustomDrawBackgroundCell(Sender: TcxCustomTreeList; ACanvas: TcxCanvas; AViewInfo: TcxTreeListCustomCellViewInfo; var ADone: Boolean);
begin
  // paint the background rectangle with the specified bitmap
  ACanvas.FillRect(AViewInfo.BoundsRect, ABitmap);
  // suppress the default painting
  ADone := True;
end;