procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  s : String ;
begin
if (acol = 2) and(arow >0) then
  begin
  StringGrid1.Canvas.Brush.Color := clred;
  StringGrid1.canvas.FrameRect(rect);
end ;
if (acol = 3) and(arow >0) then
  begin
  StringGrid1.Canvas.Brush.Color := clYellow ;
  StringGrid1.canvas.FrameRect(rect);
end ; 

解决方案 »

  1.   

    这个可能更符合你的要求:
    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    var
      s : String ;
    begin
    if (acol = 2) and(arow >0) then
      begin
      StringGrid1.Canvas.Brush.Color := clYellow ;
      StringGrid1.Canvas.pen.Color := StringGrid1.Font.Color ;
      StringGrid1.canvas.fillRect(rect);
      StringGrid1.Canvas.textout(rect.left+1,rect.Top ,StringGrid1.cells[acol,arow]);
      StringGrid1.Canvas.Brush.Color := clred;
      StringGrid1.canvas.FrameRect(rect);
      end ;
      end;
    end.