如何滚动RichTextBox到底部?
我需要能够滚动RichTextBox的底部,即使我不附加文字。 我知道我可以附加文本,然后用它来设置select开始。 不过,我想确保它是在视觉上的底部,所以我不添加任何文字。
您可以尝试将SelectionStart属性设置为文本的长度,然后调用ScrollToCaret方法。
richTextBox.SelectionStart = richTextBox.Text.Length; richTextBox.ScrollToCaret();   RichTextBox将保持滚动到最后如果它有焦点,并且您使用AppendText添加信息。 如果将HideSelection为false,则它在失去焦点并保持自动滚动时将保持其select状态。 
 我devise了一个使用下面的方法的日志查看器GUI。 它使用了一个完整的核心保持。 摆脱这个代码并将HideSelection设置为false将CPU使用率降低到1-2%。 
 //Don't use this! richTextBox.AppendText(text); richTextBox.ScrollToEnd(); 
在WPF中,您可以使用ScrollToEnd:
 richTextBox.AppendText(text); richTextBox.ScrollToEnd(); 
代码应该写在富文本框的TextChanged事件中,如:
 private void richTextBox_TextChanged(object sender, EventArgs e) { richTextBox.SelectionStart = richTextBox.Text.Length; richTextBox.ScrollToCaret(); } 
没有必要:
 richTextBox.SelectionStart = richTextBox.Text.Length; 
这是诀窍:
 richTextBox.ScrollToCaret();