Michael C wrote:
"Frank Rizzo"
<no**@none.com> wrote in message
news:uq**************@TK2MSFTNGP05.phx.gbl...
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)
{
&n bsp; PaintControlGradient(e);
}
private void PaintControlGradient(PaintEventArgs e)
{
&n bsp; Color GradientBegin = Color.White;
&n bsp; Color GradientEnd = Color.Black;
&n bsp; Rectangle rect = new Rectangle(new Point(0, 0), this.Size);
&n bsp; LinearGradientBrush gradientBrush = new LinearGradientBrush(rect, GradientBegin, GradientEnd, 90f);
&n bsp; e.Graphics.FillRectangle(gradientBrush, rect);
&n bsp; e.Graphics.DrawString("Yeah", _TextFont, _TextBrush, _TextPoint);
}