How to stop the automatic scrolling of a Memo control?

不打扰是莪最后的温柔 提交于 2019-12-19 02:52:11

问题


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

How can I stop the automatic scrolling?


回答1:


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;


来源:https://stackoverflow.com/questions/14079906/how-to-stop-the-automatic-scrolling-of-a-memo-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!