changing the background color of Selected Text in an RTB

  • Thread starter Thread starter njuneardave
  • Start date Start date
N

njuneardave

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!!!
 
Hi,

RichTextBox has a property SelectionBackColor that will change the
background color of the selected text. I think this is what you are after.
 
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!
 
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.
 

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