我的程序调用 Java,然后将标准输出重定向到 RichTextBox
。我的问题是每次写入数据时,垂直滚动条总是停留在框的顶部。
即使您滚动到底部,一旦写入新数据,它就会回到顶部。我想要相反的东西。
所以当写入新数据时,它会停留在底部。我该怎么做?
最佳答案
是的,您可以使用 ScrollToCaret()
方法:
// 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();
}
关于c# - 富文本框在写入新数据时滚动到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9416608/