默认mome的垂直滚动条隐藏,当行数超过mome的高度时再显示滚动条
如何判断啊?

解决方案 »

  1.   

    我的瞎想: 预先算出共能容得下几行,到时每增一行,就判断memo1.Lines.Count是不是大于了,大于让scrollbar出现就好了
      

  2.   

    我知道啊,但是我希望在默认的时候scollbar是隐藏的,不可见的(ssNone),而非处于无效状态
    当文字行数超过memo的高度时,scollbar才显示处理啊
    是不是我表达有问题了?
      

  3.   

    MEMO的滚动条本来就是自动的,楼主不如去看TMEMO的代码。。
      

  4.   

    把TMEMO的看懂就知道怎么在该显示的时候显示了。
      

  5.   

    谢谢 solokey(永远的菜鸟)  把我当成牛人了,可惜我不是:(
      

  6.   

    兄台,不要钻牛角尖啦,你真要那种效果吗?真要的话只有去读Tmemo...TCustomMemo...深不见底,帮不了你了,也许这和API有关吧,也许是windows的一种效果
      

  7.   

    帮你搞定了,你自己试试看
    procedure TForm1.Button1Click(Sender: TObject);
    var
      ContentHeight: Integer;
    begin
      Canvas.Font := Memo1.Font;
      ContentHeight := Canvas.TextHeight('好');
      ContentHeight := (Memo1.Lines.Count+1) * ContentHeight;
      if ContentHeight < Memo1.Height then
      begin
        Memo1.ScrollBars := ssNone;
      end
      else
      begin
        Memo1.ScrollBars := ssVertical;
      end;
    end;
      

  8.   

    或者在Memo1的onChange事件里面写
    procedure TForm1.Memo1Change(Sender: TObject);
    var
      ContentHeight: Integer;
    begin
      Canvas.Font := Memo1.Font;
      ContentHeight := Canvas.TextHeight('好');
      ContentHeight := (Memo1.Lines.Count+1) * ContentHeight;
      if ContentHeight < Memo1.Height then
      begin
        Memo1.ScrollBars := ssNone;
      end
      else
      begin
        Memo1.ScrollBars := ssVertical;
      end;
    end;