Is there a way to insert text where the text cursor is at?

blumonde

Well-known member
Joined
Jul 26, 2005
Messages
68
Programming Experience
Beginner
Gentlemen,

I have a multitext box displaying a paragraph. I would like to know how we can programmatically insert a sentence into the body of the paragraph. I know the string member "Insert" can do the inserting but I need to know a way to detect where the text cursor is at so that I can insert at its position.

For instance, first, I will place the text cursor where I want in the paragraph. And when I click a button, a line of text will go into the paragraph where the cursor was set at.

Is there a way to ascomplish this? Anyone know how we can track the index number of the text cursor?

Please shed a light on me. I am at my wits end.

Thanks.

Cheers,

blumonde
 
To replace the selected section of text in a TextBox you would use:
VB.NET:
myTextBox.SelectedText = "text to be inserted"
If the SelectionLength property is zero, i.e. no text is selected, then the value will simply be inserted at the caret position, which is stored in the SelectionStart property.
 
blumonde, I am very unimpressed with the tone of your last post, which has now been deleted. I suggest you re-read my previous post, particularly the last sentence, and try the code I suggested. You will find that it does exactly what you want. Rest assured that this is the last time you will receive any help from me.
 
Last edited:
Back
Top