我如何可以滚动到使用C#RichTextBox控件中的某一行? [英] How can I scroll to a specified line number of a RichTextBox control using C#?
本文介绍了我如何可以滚动到使用C#RichTextBox控件中的某一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何可以滚动使用C#RichTextBox控件中的某一行?这是的WinForms版本。
How can I scroll to a specified line number of a RichTextBox control using C#? It's the WinForms version.
推荐答案
您可以尝试这样的事情。
You can try something like this.
void ScrollToLine(int lineNumber)
{
if (lineNumber > richTextBox1.Lines.Count()) return;
richTextBox1.SelectionStart = richTextBox1.Find(richTextBox1.Lines[lineNumber]);
richTextBox1.ScrollToCaret();
}
这并不完美,如果你有你的RichTextBox中大量的重复工作。我希望,这可能是一些对你有用的。
This will not work perfectly if you have lots of repetition within your RichTextBox. I do hope that it might be of some use to you.
这篇关于我如何可以滚动到使用C#RichTextBox控件中的某一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文