How to stop the automatic scrolling of a Memo control?

后端 未结 1 346
清酒与你
清酒与你 2021-01-05 06:53

In Windows 7, a memo control (TMemo) will scroll automatically after text is insterted (Memo.Lines.Add(Path);), which I do not want, because scroll

相关标签:
1条回答
  • 2021-01-05 07:33

    Normally, adding text to a memo control scrolls the memo to the bottom of the inserted text. To prevent that, call Lines.BeginUpdate before adding text, and call EndUpdate afterwards:

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      Memo1.Lines.BeginUpdate;
      try
        Memo1.Lines.Add('...');
        Memo1.Lines.Add('...');
        ...
      finally
        Memo1.Lines.EndUpdate;
      end;
    end;
    
    0 讨论(0)
提交回复
热议问题