Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Selected text from a text box

Status
Not open for further replies.

TestingXSD

Programmer
Mar 24, 2002
11
US
I have a text box with HTML content. I would like the user to be able to select a portion of the text and then click a command button that would do something with that text.

I have tried to use the textbox.seltext, but you have to set focus on the textbox first, which selects everything in the box. I just need the subset that the user has selected. I am open to changing the controls type if there is one that would give the required function, as well as function as a textbox.

-T

 
You can set the TextBox.SelStart and TextBox.SelLength properties and then set the value of the SelText property which will replace the highlighted section.

That's the easy part because you need to capture the values of SelStart and SelLength, store somewhere, so that when the button is clicked, you can return the focus to the testbox, reset those to values, and perform your substitutions.

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I can capture the selStart, seltext and sellentgh in the OnExit event of the textbox. This is the only workaround I can find.

Thanks

-T
 
Sounds like you're on the right track.

Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top