When a user selects a button a custom user control is added to the form. This user control provides the ability to enter in some values.
How do I wait for the user control to complete before changing the value on my main form?
I was thinking of something like this:
customControl ylc = new customControl();
ylc.Location = new Point(11, 381);
ylc.Parent = this;
ylc.BringToFront();
if(ylc.ShowDialog() == DialogResult.OK)
{
this.lblSomeText.Text = ylc.PublicPropertyValue
}
UPDATE1
The user control can't be added to its own form. On some forms it is 'embedded-in' and on other forms it is dynamically created as needed.
UPDATE2
This SO link was helpful.
My final solution looks like (I hide the usercontrol when 'completed'):
customControl ylc = new customControl();
ylc.Location = new Point(11, 381);
ylc.Parent = this;
ylc.BringToFront();
ylc.VisibleChanged += new EventHandler(ylc_VisibleChanged);
ylc.Show();
Then this code goes in the 'Visiblechanged' event:
if(ylc.ShowDialog() == DialogResult.OK)
{
this.lblSomeText.Text = ylc.PublicPropertyValue
}