StringGrid 下横线问题  如何让
StringGrid1.Row:=5;
StringGrid1.Col:=6;
如何控制以上的StringGrid1 双下横线 和单下横线啊 就是说  我想让哪个格格的字体为 单下横线  和双下横线呢 ???
如果没办法实现 那有其它控件吗????????????? 谢谢

解决方案 »

  1.   

    至少,你可以使用ownerdraw的方法。
      

  2.   

    在DeawCell事件中自己画procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      if (ACol = 2) and (Arow = 2) then 
      begin
        StringGrid1.Canvas.Font.Style := [fsUnderLine];
        StringGrid1.Canvas.TextRect(Rect,Rect.Left + 2,Rect.Top + 2,StringGrid1.Cells[ACol,ARow]);
      end;
    end;
      

  3.   

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      if (ACol = 2) and (Arow = 2) then 
      begin
        StringGrid1.Canvas.Font.Style := [fsUnderLine];
        StringGrid1.Canvas.TextRect(Rect,Rect.Left + 2,Rect.Top + 2,StringGrid1.Cells[ACol,ARow]);
      end;
    end;
      

  4.   

    只有自己画了, miky(miky) 的方法不错
      

  5.   

    不能,因为没有双下划线这种字体风格,不知道Word是怎么做的。
    但有变通方法,算出字体的最下部分的坐标,然后用MoveTo,LineTo再画一条线。
      

  6.   

    procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    begin
      if (ACol = 2) and (Arow = 2) then 
      begin
        StringGrid1.Canvas.Font.Style := [fsUnderLine];
        StringGrid1.Canvas.TextRect(Rect,Rect.Left + 2,Rect.Top + 2,StringGrid1.Cells[ACol,ARow]);
      end;
      if (ACol = 3) and (ARow = 3) then 
        With StringGrid1.Canvas do
        begin
        Font.Style := [fsUnderLine];
        TextRect(Rect,Rect.Left + 2,Rect.Top + 2,StringGrid1.Cells[ACol,ARow]);
        //画多一条线
        MoveTo(Rect.Left + 2,Rect.Top + 3 + TextHeight(StringGrid1.Cells[ACol,ARow]));
        Pen.Color := ClBlack;         
        LineTo(Rect.Left + 2 +  TextWidth(StringGrid1.Cells[ACol,ARow]),Rect.Top + 3 + TextHeight(StringGrid1.Cells[ACol,ARow]));
        end;
    end;