Set cursor to RichTextBox

I have a simple form with a RichTextBox. In the Load event I am writing some text to the RichTextBox and now I want to set the cursor position to the end of that text so I can add something. I tried Focus () but it doesn't work

+2


source to share


2 answers


Try:



 richTextBox1.SelectionStart = richTextBox1.Text.Length;
 richTextBox1.Focus();

      

+9


source


You can use the CaretPosition property or use the Select (pos, pos) method to achieve your desired result.

Edit:



The Focus method simply moves the keyboard focus to the RichTextBox, but it does not change the current cursor position within the control.

+5


source







All Articles