1

我正在使用 RichEdit,并且正在向其中添加包含各种颜色的线条。现在我使用这种方法:

LogRichEdit.Lines.Add(someText);
...
LogRichEdit.SelStart:=res+8;
LogRichEdit.SelLength:=4;
LogRichEdit.SelAttributes.Color:=clSilver;

whereres是要格式化的文本的位置。不要管那个。我遇到的问题是,当我添加此行然后对其进行编辑时,它会闪烁(通过选择和取消选择文本)。我怎样才能以更好的方式使用它?我以为我可以拥有某种 rtf 字符串变量,用它做我的事情,然后.add将它发送到 RichEdit。或者?

4

1 回答 1

3

您应该能够通过使用BeginUpdate/来避免闪烁EndUpdate

RichEdit.Lines.BeginUpdate;
try
  // make modifications to RichEdit.Lines
finally
  RichEdit.Lines.EndUpdate;
end;

对 BeginUpdate 的调用会抑制 UI 更新,直到调用 EndUpdate。

于 2012-03-17T15:45:44.360 回答