Graphics.DrawString

  • Thread starter Thread starter Dom
  • Start date Start date
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/
 
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
 
Back
Top