with stringgrid1,stringgrid1.Canvas do
  begin
    FillRect(Rect);
    Area := Rect;
    InflateRect(Area, -2, -2);
   // if (ACol<2) or (ARow=0) then
      DrawText(Handle, PChar(Cells[ACol, ARow]),Length(Cells[ACol, ARow]), Area, DT_CENTER);//设为居中,
  end;

解决方案 »

  1.   

    TStringGrid在显示字符时,是优先从DrawCell方法中得来的,你如果在这方法
    写了満足某些条件的Cell现示情况,其它的情况没有写,那么TStringGrid的这
    些不满足条件的Cell就不会被正常的显示出来的。
    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    var Area: TRect;
    begin
      with stringgrid1,stringgrid1.Canvas do
      begin
        FillRect(Rect);
        Area := Rect;
        InflateRect(Area, -2, -2);
        if (ACol<2) or (ARow=0) then
          DrawText(Handle,
                   PChar(Cells[ACol, ARow]),
                   Length(Cells[ACol, ARow]),
                   Area,
                   DT_CENTER)//设为居中
        else
          DrawText(Handle,
                   PChar(Cells[ACol, ARow]),
                   Length(Cells[ACol, ARow]),
                   Area,
                   DT_LEFT);//其它的居左显示  end;
    end;
      

  2.   

    哎 去掉---if (ACol<2) or (ARow=0) then
    不就行了。