L
Larry
I'm sure I've missed the obvious, but when I define a custom color, my
DrawString call from my Paint event doesn't seem to draw anything at
all.
void btnNav_Paint(object sender, PaintEventArgs e)
{
SolidBrush brush1 = new SolidBrush(Color.Blue);
SolidBrush brush2 = new SolidBrush(Color.FromArgb(0x0000FF));
StringFormat format =
(StringFormat)StringFormat.GenericTypographic.Clone();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
Rectangle drawingRect = ClientRectangle;
drawingRect.Inflate(-15, 0);
e.Graphics.DrawString("Text", this.Font, brush1, drawingRect,
format);
//e.Graphics.DrawString("Text", this.Font, brush2, drawingRect,
format);
}
When I use brush1, the text draws correctly. When I use brush2,
nothing seems to draw at all. Any color I create with Color.FromArgb()
fails, but the standard colors all work.
This code is in an object derived from Label. I just chained in my
Paint event handler, so the base class Paint is still being called:
this.Paint += new PaintEventHandler(btnNav_Paint);
I can't figure out why a custom color behaves differently from a
standard color. Any ideas?
DrawString call from my Paint event doesn't seem to draw anything at
all.
void btnNav_Paint(object sender, PaintEventArgs e)
{
SolidBrush brush1 = new SolidBrush(Color.Blue);
SolidBrush brush2 = new SolidBrush(Color.FromArgb(0x0000FF));
StringFormat format =
(StringFormat)StringFormat.GenericTypographic.Clone();
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
Rectangle drawingRect = ClientRectangle;
drawingRect.Inflate(-15, 0);
e.Graphics.DrawString("Text", this.Font, brush1, drawingRect,
format);
//e.Graphics.DrawString("Text", this.Font, brush2, drawingRect,
format);
}
When I use brush1, the text draws correctly. When I use brush2,
nothing seems to draw at all. Any color I create with Color.FromArgb()
fails, but the standard colors all work.
This code is in an object derived from Label. I just chained in my
Paint event handler, so the base class Paint is still being called:
this.Paint += new PaintEventHandler(btnNav_Paint);
I can't figure out why a custom color behaves differently from a
standard color. Any ideas?