在 .StringGrid1DrawCell 事件中写上 if ARow>0 then begin if ARow mod 2 = 0 then StringGrid1.Canvas.Brush.Color := $00DBDBDB else StringGrid1.Canvas.Brush.Color := clWhite; StringGrid1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,StringGrid1.cell[ACol,ARow]); end;
procedure TForm_Main.DrowColorOnCell(stringgrid:Tstringgrid;ACol, ARow: Integer; Rect: TRect); begin with stringgrid do begin if (ACol > 0) and (ARow > 0) then begin if (ARow mod 2=0) then Canvas.Brush.Color := clskyblue else Canvas.Brush.Color:=$00EBDDD3; Canvas.FillRect(Rect); Canvas.Font.Name := 'Courier New'; Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]); end; end; end; 这样就可以了!
if ARow>0 then begin
if ARow mod 2 = 0 then
StringGrid1.Canvas.Brush.Color := $00DBDBDB
else
StringGrid1.Canvas.Brush.Color := clWhite;
StringGrid1.Canvas.TextRect(Rect,Rect.Left,Rect.Top,StringGrid1.cell[ACol,ARow]);
end;
begin
with stringgrid do
begin
if (ACol > 0) and (ARow > 0) then
begin
if (ARow mod 2=0) then
Canvas.Brush.Color := clskyblue
else
Canvas.Brush.Color:=$00EBDDD3;
Canvas.FillRect(Rect);
Canvas.Font.Name := 'Courier New';
Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
end;
end;
end;
这样就可以了!