Skip to main content

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:

//...
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;
See Also