Set cursor in RichTextBox

后端 未结 3 924
别跟我提以往
别跟我提以往 2021-01-21 12:15

I\'ve got a simple form with RichTextBox on it. In Load event, I write some text to RichTextBox and now I want to set cursor location to the end of this text so I can add someth

相关标签:
3条回答
  • 2021-01-21 12:34

    Try :

     richTextBox1.SelectionStart = richTextBox1.Text.Length;
     richTextBox1.Focus();
    
    0 讨论(0)
  • 2021-01-21 12:46

    For winform application simple add this command SendKeys.Send("{RIGHT}"); after richTextBox1.AppendText("foo"); or richTextBox1.Paste(); then `richTextBox1.Focus();'

    0 讨论(0)
  • 2021-01-21 12:48

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

    Edit:

    The Focus method just moves the keyboard focus to your RichTextBox, but it doesn't alter the current position of the cursor inside the control.

    0 讨论(0)
提交回复
热议问题