By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,961 Members | 2,492 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,961 IT Pros & Developers. It's quick & easy.

changing the background color of Selected Text in an RTB

P: n/a
Hey!

One quick question: It's really easy to change the background color of
an entire RTB, but I have looked and looked and can't find a way to
change the background color of the selected text in an RTB. Anyone
know how?

Any help is greatly appreciated!!!

Sep 22 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

RichTextBox has a property SelectionBackColor that will change the
background color of the selected text. I think this is what you are after.
--
HTH
Stoitcho Goutsev (100)

"njuneardave" <da**********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hey!

One quick question: It's really easy to change the background color of
an entire RTB, but I have looked and looked and can't find a way to
change the background color of the selected text in an RTB. Anyone
know how?

Any help is greatly appreciated!!!

Sep 22 '06 #2

P: n/a
Stoitcho,

Thanks for the answer, but unfortunately, I forgot to mention that I am
using .NET 2003, and I do not see this option. Any other advice?
Thanks again!

Stoitcho Goutsev (100) wrote:
Hi,

RichTextBox has a property SelectionBackColor that will change the
background color of the selected text. I think this is what you are after.
--
HTH
Stoitcho Goutsev (100)

"njuneardave" <da**********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hey!

One quick question: It's really easy to change the background color of
an entire RTB, but I have looked and looked and can't find a way to
change the background color of the selected text in an RTB. Anyone
know how?

Any help is greatly appreciated!!!
Sep 25 '06 #3

P: n/a
Yes, this is unfortunate. In this case you have no other option but to use
PInvoke and send EM_SETCHARFORMAT message to the RichEditBox using
CHARTFROMAT2 structure; this structure has crBackColorField.
--
HTH
Stoitcho Goutsev (100)

"njuneardave" <da**********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Stoitcho,

Thanks for the answer, but unfortunately, I forgot to mention that I am
using .NET 2003, and I do not see this option. Any other advice?
Thanks again!

Stoitcho Goutsev (100) wrote:
>Hi,

RichTextBox has a property SelectionBackColor that will change the
background color of the selected text. I think this is what you are
after.
--
HTH
Stoitcho Goutsev (100)

"njuneardave" <da**********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googleg roups.com...
Hey!

One quick question: It's really easy to change the background color of
an entire RTB, but I have looked and looked and can't find a way to
change the background color of the selected text in an RTB. Anyone
know how?

Any help is greatly appreciated!!!

Sep 25 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.