Graphics.DrawString

D

Dom

In a control's OnPaint, I do the following:

e.Graphics.DrawString (Text, MyFont, Brushes.Red, MyRect)

The purpose of the "Brushes.Red" is to highlight the word, but I would
like to highlight in the usual way, with a gray rectangular
background. Nothing in DrawString lets be change the background color
of MyRect. Am I missing something/
 
P

Peter Duniho

Dom said:
In a control's OnPaint, I do the following:

e.Graphics.DrawString (Text, MyFont, Brushes.Red, MyRect)

The purpose of the "Brushes.Red" is to highlight the word, but I would
like to highlight in the usual way, with a gray rectangular
background. Nothing in DrawString lets be change the background color
of MyRect. Am I missing something/

Yes. Just draw the rectangle in your desired color before drawing the
string itself.

Pete
 

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

Top