I am printing a lot of text to a textbox an开发者_如何学运维d would like it to scroll to the top after the printing is complete.
Set the SelectionStart = 0;
for your TextBox. See here at MSDN about SelectionStart. You can then set your SelectionLength = 1;
You can then call ScrollToCaret.
textbox.SelectionStart = 0;
that works in Wpf and in WinForms Applications
For WinForms, use a combination of SelectionStart = 0 and ScrollToCaret()
Just use navigation keys after making sure the control has focus:
SendKeys.Send("^({HOME})");
SendKeys.Send("^({END})");
etc. as needed
SelectionStart = 0
did not work for me.
I used richTextBox1.Clear();
before loading new text.
精彩评论