RichTextBox滚动条
我不确定 Visual Studio C# Windows 应用程序中的 RichTextBox 发生了什么。这不是网络应用程序。
我有一个处理多个文件的过程。在处理过程中,它使用 AppendText 在 RichTextBox 中发布进度报告。 (添加的内容具有换行符,使内容保持整洁。)此过程已从一个应用程序迁移到另一个应用程序。新应用程序中的表单是使用新的 RichTextBox 从头开始创建的,并复制了代码。
在原来的应用程序上,当消息到达框的底部时,它们开始滚动,以便新的文本行始终可见。在新的应用程序上,它不会滚动(尽管我希望它滚动),因此新消息(包括指示该过程已完成的最后一条消息)在底部下方看不见。我比较了这两个程序,没有看出区别。我不知道如何控制这种行为。过程中可能存在影响焦点、刷新行为等的差异。
我应该去哪里看?
I'm not sure what is going on with a RichTextBox in a Visual Studio C# windows application. This is not a web app.
I have a procedure that processes several files. As it processes, it posts progress reports in the RichTextBox using AppendText. (The additions have newline chars which keep things neat.) This procedure was migrated from one app to another. The form in the new app was created from scratch with a new RichTextBox, and the code was copied.
On the original app, when the messages reach the bottom of the box, they begin to scroll so the new line of text is always visible. On the new app, it does not scroll (though I want it to) so the new messages (including the last one that indicates the process is done) are out of sight below the bottom. I've compared the two programs, and I don't see the difference. I don't see how this behavior would be controlled. It is possible that there is a difference in the procedure that affects focus, or refresh behavior, or whatever.
Where should I look?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以添加您的消息,以便最新消息始终位于顶部吗?
You could just prepend your messages such that the newest message is always on the top?
如果你想保留选择,你需要存储
SelectionStart
和SelectionLength
并在滚动后恢复选择。if you want to keep the selection you need to store
SelectionStart
andSelectionLength
and restore the selection after the scroll.