Calling Invalidate on Custom Control Causes Other Controls to Stop Rendering...

A

Alexander Jhin

I have this very basic Custom Control:
public class TestPanel : Panel
{
public TestPanel() : base()
{
this.SetStyle(
ControlStyles.AllPaintingInWmPaint |
ControlStyles.Opaque |
ControlStyles.UserPaint,
true);
}

protected override void OnPaint(PaintEventArgs e)
{
Invalidate(false);
base.OnPaint(e);
}
}
When I add it to a form, OTHER controls in the same form stop
rendering correctly (you can see the desktop where buttons should be,
text boxes only display text when you click on them, etc.)

Anyone know why this is happening? Thanks in advance.
 
C

Chris Dunaway

protected override void OnPaint(PaintEventArgs e)
{
Invalidate(false);
base.OnPaint(e);
}
}

I may be wrong, but I think you are getting into a loop. Invalidate()
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
causes your OnPaint method to be called which calls Invalidate() which
....


--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

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