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 Data Cells

The following example demonstrates how to handle the tree list’s OnCustomDrawDataCell event, used to manually paint data cells.

In the example, only selected data cells are custom painted. For the required result, the following settings have been specified: the tree list’s OptionsSelection.CellSelect property is True, and the OptionsSelection.InvertSelect property is False.

// Delphi

// …

procedure <Form>.<TreeList>CustomDrawDataCell(Sender: TcxCustomTreeList; ACanvas: TcxCanvas; AViewInfo: TcxTreeListEditCellViewInfo; var ADone: Boolean);
begin
  if not AViewInfo.Selected then Exit
  else
  begin
    //paint the focused node
    ACanvas.Brush.Color := $80FFFF;
  end;
end;

This is the code execution result: