delphi TreeView修改选中的节点的颜色和背景-LMLPHP
 
TreeView修改选中的节点的颜色和背景
 
  TCustomDrawTarget = (dtControl, dtItem, dtSubItem);
  TCustomDrawStage = (cdPrePaint, cdPostPaint, cdPreErase,
cdPostErase);
  TCustomDrawState = set of (cdsSelected, cdsGrayed, cdsDisabled,
cdsChecked,
    cdsFocused, cdsDefault, cdsHot, cdsMarked,
cdsIndeterminate);



procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);

begin

    if (cdsSelected in State) then

   begin

      with Sender.Canvas do

      begin

        Brush.Color :=clBlue;

        Font.Color :=clRed;

        Font.Size := 11;

        Font.Style:=[fsBold];

      end;

   end;
end;



如何画图片 节点的整行的
procedure TForm1.TreeView1AdvancedCustomDraw(Sender:
TCustomTreeView;
const ARect: TRect; Stage: TCustomDrawStage; var
DefaultDraw: Boolean);
procedure TForm1.TreeView1AdvancedCustomDrawItem(Sender:
TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; Stage:
TCustomDrawStage;
var PaintImages, DefaultDraw:
Boolean);
 
procedure TForm1.TreeView1CustomDraw(Sender:
TCustomTreeView;
const ARect: TRect; var DefaultDraw:
Boolean);
 
procedure TForm1.TreeView2CustomDrawItem(Sender:
TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw:
Boolean);
 
04-25 17:03