Michael C wrote:
"Frank Rizzo"
<[email protected]> wrote in message
news:[email protected]...
Try the onpaint override instead.
Tried it. Same thing happened.
Do you do a this.Validate() anywhere in the paint? Can you post a simplified sample that demonstrates the problem?
Here is the sample. All this is inside of a user control. The control is inside another control which is inside a form.
The user presses Alt and then for about a second whatever I painted disappears and then reappears again (because the OnPaint event fired).
private static Font _TextFont = new Font("Tahoma", 11f, FontStyle.Bold);
private static Brush _TextBrush = new SolidBrush(SystemColors.Window);
private static PointF _TextPoint = new PointF(6f, 2f);
protected override void OnPaint(PaintEventArgs e)
{
PaintControlGradient(e);
}
private void PaintControlGradient(PaintEventArgs e)
{
Color GradientBegin = Color.White;
Color GradientEnd = Color.Black;
Rectangle rect = new Rectangle(new Point(0, 0), this.Size);
LinearGradientBrush gradientBrush = new LinearGradientBrush(rect, GradientBegin, GradientEnd, 90f);
e.Graphics.FillRectangle(gradientBrush, rect);
e.Graphics.DrawString("Yeah", _TextFont, _TextBrush, _TextPoint);
}