TextBox, Set Caret position

B

bert

I am writing my first windows form application to be used to test
database performance. I am using a multi-line textbox control to give
the user feedback of what is being processed. This is the code I am
using to add

xtQueryStatus.Text += "New Data";
txtQueryStatus.Text += System.Environment.NewLine;

When the box becomes filled up I would like the text box to scroll.
The textbox has 8 lines so I would like it to display the last eight
lines.

I looked at the docs and looked at the ScrollToCaret. So I need to set
the Caret to 8 lines from the end and call the ScrollToCaret method.
but I do not know how to set the Caret position.

Thanks

Bert
 
H

Herfried K. Wagner [MVP]

bert said:
I looked at the docs and looked at the ScrollToCaret. So I need to set
the Caret to 8 lines from the end and call the ScrollToCaret method.
but I do not know how to set the Caret position.

'SelectionStart'/'SelectionLength' or an overloaded version of the textbox's
'Select' method.

Adding a line to a richtextbox and scrolling it into view
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=richtextboxscrolltobottom&lang=en>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top