丰富的文本框滚动至底部时,新的数据写入到它 [英] Rich Text box scroll to the bottom when new data is written to it

查看:138
本文介绍了丰富的文本框滚动至底部时,新的数据写入到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序调用Java和再标准输出重定向到的RichTextBox 。我的问题是垂直滚动条始终保持在每次写入数据的箱的顶部。

My program calls Java and then redirects stdout to a RichTextBox. My problem is that the vertical scrollbar always stays at the top of the box every time data is written.

即使你的滚动至底部,一旦新数据被写入它进入到顶部。我想的相反

Even if you scroll to the bottom, once new data has been written it goes to the top. I would like the opposite.

因此​​,当新的数据被写入时,它停留在底部。我怎样才能做到这一点?

So when new data is written, it stays at the bottom. How can I do this?

推荐答案

是的,你可以使用的 ScrollToCaret() 方法

Yes, you can use the ScrollToCaret() method:

// bind this method to its TextChanged event handler:
// richTextBox.TextChanged += richTextBox_TextChanged;
private void richTextBox_TextChanged(object sender, EventArgs e) {
   // set the current caret position to the end
   richTextBox.SelectionStart = richTextBox.Text.Length;
   // scroll it automatically
   richTextBox.ScrollToCaret();
}

这篇关于丰富的文本框滚动至底部时,新的数据写入到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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