1

How paste text from clipboard to the cursor area in a textbox?
With code below we can change entire text of textbox :

 radTextBox1.Text = Clipboard.GetText();

But what about pasting on cursor area?

SilverLight
  • 17,622
  • 58
  • 171
  • 277
  • Checkout this [answer](https://stackoverflow.com/questions/1416454/how-to-paste-text-in-textbox-current-cursor) – squareskittles May 02 '19 at 13:24
  • Possible duplicate of [How to paste text from clipboard into selected textbox using a button](https://stackoverflow.com/questions/36816915/how-to-paste-text-from-clipboard-into-selected-textbox-using-a-button) – zaggler May 02 '19 at 13:26
  • 1
    It's not dup. The answer below is better. – SilverLight May 02 '19 at 13:38

1 Answers1

3

Try this:

radTextBox1.Paste(Clipboard.GetText());

Paste inserts your new text at the current cursor position. If your textbox has highlighted text, Paste will replace the hightlighted text with your new text. Here are the docs.

squareskittles
  • 11,997
  • 7
  • 31
  • 48
  • This is true if by 'cursor' op means the insertion point. If he means the mouseposition, a call to `GetCharIndexFromPosition` first, would help.. – TaW May 02 '19 at 13:37