delphi StringGrid背景色隔行显示

来源:互联网 发布:adas模型 知乎 编辑:程序博客网 时间:2024/05/21 06:39

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
      if   (ARow mod 2=1)  then
      begin
          StringGrid1.Canvas.Font.Color   :=   clred;
          StringGrid1.Canvas.Brush.Color :=$00FFF0F5;
          StringGrid1.Canvas.TextRect(rect,rect.Left,rect.Top,StringGrid1.Cells[acol, arow]);
          StringGrid1.Canvas.FrameRect(Rect);
      end;
end;

原创粉丝点击