I am trying to create a lightbox effect within my application. To achieve this, I have a UserControl with a panel representing the semi-transparent overlay and a seperate panel hosting all the necessary content.
When I show this UserControl It often attempts to render itself 2-3 times causing the background to appear to get darker and darker. I thought about doing the following in the UserControl
protected override void OnPaint ( PaintEventArgs e )
{
if ( Parent != null )
{
Parent.Refresh();
}
base.OnPaint( e );
}
unfortunatly, this appears to cause a horrible loop-effect whereby the Parent red-raws itelf and then teh UserControl redraws itelf... very messy. Is there a way of somehow stopping this? possibly by taking a printscreen image from the application, displaying that in the user control with the overlay ontop?
EDIT
I have noticed this question although Im hoping that I don't need to create a new form for every lightbox I create!