Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the RichTextBox curser to the end?

Tags:

c#

I am using System.Windows.Forms.RichTextBox and doing something like

RichTextBox1.Text = "Hello World";

But after this statement the cursor position of in the RichTextBox remains in the beginning. Is there any way to set it to the end?

like image 622
Mohammad Nadeem Avatar asked Dec 13 '25 04:12

Mohammad Nadeem


1 Answers

This should do it for you:

RichTextBox1.Select(RichTextBox1.Text.Length - 1, 0);

Edit: If you have a lot of text in the textbox and which it to scroll the caret into view too, add this line:

RichTextBox1.ScrollToCaret();

See msdn for more.

like image 140
Pondidum Avatar answered Dec 14 '25 18:12

Pondidum