Igor Marvinsky
Igor Marvinsky

Reputation: 387

Event to update a control in the right moment

I have a User Control displaying some data and a button that displays a popup that allows the user to add data. Then the users enters the data and clicks OK and the pop-up closes. The problem is that the form still displays the old data. To what event should I wire DataReload() to see the change immediately?

Upvotes: 0

Views: 76

Answers (2)

Richard Anthony Hein
Richard Anthony Hein

Reputation: 10650

Handle the FormClosed event of your popup:

popUp.FormClosed += (o, e) => DataReload();

Upvotes: 1

Jason Williams
Jason Williams

Reputation: 57892

What is the "popup"? A dialog?

If it is shown modally with ShowDialog(), then it will not return until the user hits OK and it returns its result, so you can just call DataReload() right afterwards, as in:

MyDialog dlg = new MyDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
    DataReload();
}

Upvotes: 0

Related Questions