I'm updating my text box with text using a timer. Each time timer ticks I'm being redirected to the beginning to the text typed in my multiline text box.
How to do this?
To position the cursor at the end of the contents of a TextBox control, call the Select method and specify the selection start position equal to the length of the text content, and a selection length of 0.
Step 1: Create a windows form. Step 2: Drag the TextBox control from the ToolBox and drop it on the windows form. You can place TextBox anywhere on the windows form according to your need. Step 3: After drag and drop you will go to the properties of the TextBox control to set the Multiline property of the TextBox.
Document. Body. ScrollIntoView(false); The boolean parameter for ScrollIntoView () is true to align the scrollbar with the top of the document, and false to align the scrollbar with the bottom of the document.
I'd say that when you refresh, you could move the selection cursor to the end, then scroll the textbox 'til it's visible using ScrollToCaret.
That'll be something like
yourtextbox.SelectionStart = yourtextbox.Text.Length
yourtextbox.ScrollToCaret()
This works much better. It's better than Kotch's solution because there is no need constantly updating the position of cursor.
txtDisplay.AppendText(txtDisplay.SelectedText);
Try using the TextBox.Select
method:
textBox.Select(textBox.Text.Length, 0);
That will set the cursor to just past the last character in the text box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With