画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;

你可能感兴趣的:(String)