0

Hello! I'm trying to use code to write to a text box - I know my strings are valid and that the function I'm using to generate them works, because I can successfully display them in a pop-up.

Now I want to insert my string into a textbox at the location of the cursor.

This is the code I'm currently using

string inClip = (string)Clipboard.GetText();
string outClip = "";
MessageBox.Show(inClip);
outClip = makeNumeric(inClip, true);// a function to make the inputted string numeric...
MessageBox.Show(outClip);
textBox1.Text.Insert(textBox1.SelectionStart, outClip);
e.Handled = true;

I'm not receiving errors. I'm not positive I'm going about this in the correct manner so if there is a better method please suggest!

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Pokenerd
0
textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, outClip);

This solved the problem entirely!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.