在执行语法突出显示时,如何防止自动滚动富文本框?

时间:2021-07-02 15:49:13
  • Language = C#
  • 语言= C#

  • .NET version = 3.5
  • .NET版本= 3.5

When my code performs syntax highlighting the text appears, to the user, to be scrolling automatically. This becomes a severe problem when there is several hundred lines of text in the rich text box. So, how can I programmatically modify the text's color without causing the user to see anything other than the color change?

当我的代码执行语法高亮显示时,文本对用户显示为自动滚动。当富文本框中有几百行文本时,这将成为一个严重的问题。那么,如何以编程方式修改文本的颜色而不会让用户看到除颜色变化之外的任何内容?

Thanks for any and all assistance.

感谢您的任何和所有帮助。

1 个解决方案

#1


Have you tried something like this:

你尝试过这样的事情:

Save selstart position. 
Disable updates to the text box.  
Apply syntax highlighting.
Set selstart to saved value.  
Enable updates.

#1


Have you tried something like this:

你尝试过这样的事情:

Save selstart position. 
Disable updates to the text box.  
Apply syntax highlighting.
Set selstart to saved value.  
Enable updates.