Inserting string at cursor position in textbox

  • Thread starter Thread starter Paddy
  • Start date Start date
P

Paddy

Given

textBox1
string textBoxMsg
string Wrd

How do you insert Wrd in textBoxMsg at the cursor position in textBox1?

Thanks.
 
Paddy said:
Given

textBox1
string textBoxMsg
string Wrd

How do you insert Wrd in textBoxMsg at the cursor position in textBox1?

Hi Paddy,

textBox1.SelectedText = Wrd;

Cheers

Arne Janning
 
Given

textBox1
string textBoxMsg
string Wrd

How do you insert Wrd in textBoxMsg at the cursor position in textBox1?

Thanks.

Hi,

first get the cursor position:
int nCursorPosition = textBox1.SelectionStart;

then insert the Wrd in textBoxMsg:
textBoxMsg = textBoxMsg.Insert (iCursorPosition, wrd);

And that's it.

Regards,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top