How to "get" text in text area?


I'm developing a toolbar for Internet Explorer...
One of its functions, is to surround text in a text area with attributes....

In other words... if the user is typing something (like this question I'm typing),
then he/she selects a sentence like: Word Word Word Word
then click a button on toolbar that will "process" the selected word/sentence...

By process I mainly mean adding an attribute before/after the sentence...
so it becomes something like:
[b] Word Word Word Word [/b]
or <i > Word Word Word Word </i >

So my questions:
- how to get the selected text only (not the un-selected text in the same textbox)... ?
- Once the string is captured, how to return the selected/marked text to the textbox with the attributes??

I hope I was able to explain what I need :)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mary_MAuthor Commented:
> Guru on this subject..

I thought the this should be the level of the person who is answering the question (not me) :-)
But after posting the question, I found that label:

Author:  mary_M, Limited Member
Guru on this subject.

Well... I am NOT Guru on this subject... it was a mistake, sorry :)
Hi Mary,
You need to use Rich Text Box control instead of textbox to achieve the functionality you are asking.
Under button's click event add the following code ...
            int selectedTextLength = richtextBox.SelectedText.Length;
            if (selectedTextLength > 0)
                richtextBox.SelectionFont = new Font(richtextBox.Font.Name, richtextBox.Font.Size,               FontStyle.Bold);

Let me know for further assistance.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.