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 = "";
outClip = makeNumeric(inClip, true);// a function to make the inputted string numeric...
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!

textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, outClip);

This solved the problem entirely!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.