RichTextBox C# Set caret location winforms

后端 未结 4 352
情书的邮戳
情书的邮戳 2021-01-22 15:38

I am building a chat application where the user enters its text to a richtextbox.

In the rich text box there is an initial text which says: \"Me: \".

Now, when

4条回答
  •  一生所求
    2021-01-22 16:07

    Found it googling on the property SelectionProtected

    richTextBoxUserText.Text = INITIAL_TEXT;
    richTextBoxUserText.SelectAll();
    richTextBoxUserText.SelectionColor = Color.Red;
    richTextBoxUserText.SelectionProtected = true;
    richTextBoxUserText.SelectionLength = 0;
    richTextBoxUserText.SelectionStart = richTextBoxUserText.TextLength + 1;
    

提交回复
热议问题