我如何滚动一个RichTextBox的底部? [英] How do I scroll a RichTextBox to the bottom?

查看:147
本文介绍了我如何滚动一个RichTextBox的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够以一个RichTextBox滚动至底部,即使我不追加文本。我知道我可以追加文本,然后用它来设置选择开始。不过,我想,以确保它是在底部视觉的原因,所以我不加入任何文字。

I need to be able to scroll a RichTextBox to the bottom, even when I am not appending text. I know I can append text, and then use that to set the selection start. However I want to ensure it is at the bottom for visual reasons, so I am not adding any text.

推荐答案

您可以尝试在SelectionStart属性设置为文本的长度,然后调用ScrollToCaret方法。

You could try setting the SelectionStart property to the length of the text and then call the ScrollToCaret method.

richTextBox.SelectionStart = richTextBox.Text.Length;
richTextBox.ScrollToCaret();

这篇关于我如何滚动一个RichTextBox的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆