private void rtbLog_TextChanged(object sender, EventArgs e)
{
rtbLog.SelectionStart = rtbLog.Text.Length; //Set the current caret position at the end
rtbLog.ScrollToCaret(); //Now scroll it automatically
}
本文介绍了一个简单的C#方法,用于实现在RichTextBox中输入文本时,使文本编辑区域自动滚动到最新输入的内容处。这对于实时日志显示等功能非常有用。
private void rtbLog_TextChanged(object sender, EventArgs e)
{
rtbLog.SelectionStart = rtbLog.Text.Length; //Set the current caret position at the end
rtbLog.ScrollToCaret(); //Now scroll it automatically
}
1918
2112
1865

被折叠的 条评论
为什么被折叠?