很简单,双击dbgrid到Columns编辑下,可以设置每一个的对齐属性了

解决方案 »

  1.   

    很简单,双击dbgrid到Columns编辑下,可以设置每一个的对齐属性了
    设置Alignment为TaCenter
      

  2.   

    双击dbgrid到Columns编辑下,全部选中后即可.
      

  3.   

    错了,我用的是stringgrid,如何做
      

  4.   

    if (ARow>0) and (ACol<3) then   //设置左对齐
        begin
            SetTextAlign(StringGridDisplay.Canvas.Handle,TA_Left);
            StringGridDisplay.Canvas.FillRect(Rect);
            StringGridDisplay.Canvas.TextRect(Rect,Rect.Left+5,rect.Top+5,StringGridDisPlay.Cells[acol,arow]);
        end else
        if (ARow>0) and (ACol>3) then //设置右对齐
        begin
            SetTextAlign(StringGridDisplay.Canvas.Handle,TA_Right);
            StringGridDisplay.Canvas.FillRect(Rect);
            StringGridDisplay.Canvas.TextRect(Rect,Rect.Right-2,Rect.Top+5,StringGridDisPlay.Cells[acol,arow]);
        end;
    自己去改改,行的.
      

  5.   

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    var S: String;
    begin
      StringGrid1.Canvas.FillRect(Rect);
      S := StringGrid1.Cells[ACol,ARow];
      DrawText(StringGrid1.Canvas.Handle, PChar(S), Length(S), Rect, DT_CENTER);end;
      

  6.   

    to  borlandor(大民) 
    这样好象是只是在那个cell中横向对齐,我要的是在那个cell的中间(横向和纵向),如何做?
      

  7.   

    那得自己写一个函数了.
    可以参见
    http://www.csdn.net/Develop/read_article.asp?id=8396
    中的WriteText.