OnPaint event during a callback when the form is below?

Posted by Martín Marconcini on Stack Overflow See other posts from Stack Overflow or by Martín Marconcini
Published on 2010-05-06T13:16:40Z Indexed on 2010/05/06 15:08 UTC
Read the original article Hit count: 214

Filed under:
|
|
|

Imagine the following scenario:

this.SetStyle(ControlStyles.UserPaint, true); //this doesn’t change anything

…

void OpenSomeForm()
{
    SomeForm sf = new SomeForm();
    sf.SomeEvent += new … (SomeEventOcurred);
    sf.ShowDialog();
}

private void SomeEventOcurred(…)
{
    OnePanelInThisForm.Invalidate();
}

private void OnePanelInThisForm_Paint(object sender, PaintEventArgs e)
{
     DoSomeDrawing(e.Graphics);
}

Now, OnePanelInThisForm draws correctly when the form loads. But if SomeEventOcurred is Fired from “SomeForm”, the paint event is not fired. If I close and reopen the form it correctly repaints. If I add a button to the form that executes: OnePanelInThisForm.Invalidate(); the panel is correctly repaint.

What am I missing?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about onpaint