cxTreeList添加行号

cxTreeList添加行号(2011-11-17 15:59:38)转载
与cxGrid添加行号类似:

1.将TcxTreeList的OptionsView --> Indicator设置为true,另也可在这将indicatorWidth根据自己需要设置

2.添加OnCustomDrawIndicatorCell事件:

procedure TFTest.qtxmListCustomDrawIndicatorCell(Sender: TcxCustomTreeList;
  ACanvas: TcxCanvas; AViewInfo: TcxTreeListIndicatorCellViewInfo;
  var ADone: Boolean);
var
  AIndicatorViewInfo: TcxTreeListIndicatorCellViewInfo;
  ATextRect: TRect;
  aCV:TcxCanvas;
begin
  inherited;
  if not (AViewInfo is TcxTreeListIndicatorCellViewInfo) then Exit;
  aCV:=ACanvas ;
  ATextRect:=AViewInfo.TextBounds;
  AIndicatorViewInfo := AViewInfo as TcxTreeListIndicatorCellViewInfo;
  InflateRect(ATextRect, -2, -1);
  if AIndicatorViewInfo.Node=nil then exit;
  Sender.LookAndFeel.Painter.DrawHeader(ACanvas, AViewInfo.TextBounds,
    ATextRect, [], cxBordersAll, cxbsNormal, taCenter, TcxAlignmentVert(vaCenter),
    False, False, IntToStr(AIndicatorViewInfo.Node.AbsoluteIndex + 1),
    acv.Font,acv.font.Color,acv.Brush.Color);
  ADone := True;
end;

你可能感兴趣的:(list)