Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为了将光标移动到最后一个位置,我使用以下代码(效果很好)
rtbLog.SelectionStart = rtbLog.Text.Length; rtbLog.ScrollToCaret();
如何将光标移动到 RichTextBox 最后一行的第一个位置?
您可以使用的最后一个索引来做到这一点Environment.Newline:
Environment.Newline
rtbLog.SelectionStart = rtbLog.Text.LastIndexOfAny(Environment.NewLine.ToCharArray()) + 1 ; rtbLog.ScrollToCaret();