画Stringgrid斑马线

procedure TformRule.StringGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
begin
  if (ARow = 0) or (ACol = 0) then
    exit;
  with sender as tstringgrid do     //斑马线效果
    with canvas do
    begin
      if (arow mod 2 = 0) then
      begin
        brush.Color:=clMoneyGreen;
        font.Color:=clblack;
        fillrect(rect);
        textout(rect.Left+2,rect.Top+2,cells[acol,arow]);
      end else begin
        brush.Color:=clWindow;
        font.Color:=clblack;
        fillrect(rect);
        textout(rect.Left+2,rect.Top+2,cells[acol,arow]);
      end;
    end;
end;

posted @ 2009-12-20 13:11  delphi中间件  阅读(511)  评论(0编辑  收藏  举报