-1

What is the internal logic of RichTextBox.Paste() method which pastes data from clipboard to RichTextBox. Actually I want to add text to RichTextBox at the location where cursor is there on button click. But when I add text the added text is either selected after addition or the cursoe location is at the start of added text.

Any solution for this ?

4

1 回答 1

1

我认为您不需要知道控件的 .NET 实现。它是你我的“黑匣子”。但是,您可以取消选择并将光标移动到文本的末尾(这 2 件事会打扰您,不是吗?)

将光标移动到位置 0(开始):

richTextBox1.Select(0, 0);

移动到最后:

richTextBox1.Select(richTextBox1.Text.Length, 0);

选择所有文本:

richTextBox1.Select(0, richTextBox1.Text.Length);

取消全选并移到最后:

richTextBox1.Select(richTextBox1.Text.Length, richTextBox1.Text.Length);
于 2012-01-23T07:09:57.907 回答