在 richTextBox 中选择文本时禁用滚动 (C#)
我有一个包含(很多)文本的富文本框。我为其添加了一个搜索选项,当用户按下搜索按钮时,程序将所有匹配项标记为黄色(通过对每个选择执行选择BackColor),然后选择第一个匹配项。 结果是程序看起来像是“扫描”文本,然后选择第一个匹配项。 我不希望发生这种情况,因此我需要禁用特定代码段的自动滚动(在执行 Select() 时发生)。 我在发布之前搜索了这个问题,我发现的主要主题涉及附加文本,但这不是我的情况。 知道如何解决我的问题吗?
我使用 .NET Framework 4 (Visual Studio 2010) 并用 C# 编写。
提前致谢, 盖伊
I have a rich text box that contains (a lot of) text. I've added a search option for it, and when the user presses the search button, the program marks all the matches in yellow (by performing selectionBackColor on each selection) and then selects the first match.
The result is that the program looks like it "scans" the text and then selects the first match.
I don't want this to happen so I need to disable the autoscrolling (that occurs when performing Select()) for a specific code segment.
I searched this problem before posting and the main topics I found involved appending text, and that's not my case.
Any idea of how to solve my problem?
I'm using .NET framework 4 (visual studio 2010) and I write in C#.
Thanks in advance,
Guy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,看来我会回答我自己的问题 - 我所要做的就是将这两行与另一个类的属性放在一起:
并在开头用 this 包围所需的代码段:
在末尾用 this 包围:
Well it seems that I'll answer my own question - all I had to do was to put these two lines among with the other class's properties:
and surround the desired code segment with this at the start:
and this at the end: