title: Add something like ShowDialog to a custom User Control?
body: <p>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.</p>
  
  <p>How do I wait for the user control to complete before changing the value on my main form?</p>
  
  <p>I was thinking of something like this:</p>
  
  <pre><code>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
  }
  </code></pre>
  
  <p><strong>UPDATE1</strong></p>
  
  <p>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.</p>
  
  <p><strong>UPDATE2</strong></p>
  
  <p>This SO <a href="https://stackoverflow.com/questions/2462105/how-to-detect-when-window-is-closed-when-using-show-in-winforms-c">link</a> was helpful.</p>
  
  <p>My final solution looks like (I hide the usercontrol when 'completed'):</p>
  
  <pre><code>customControl ylc = new customControl();
  ylc.Location = new Point(11, 381);
  ylc.Parent = this;
  ylc.BringToFront();
  ylc.VisibleChanged += new EventHandler(ylc_VisibleChanged);    
  ylc.Show();
  </code></pre>
  
  <p>Then this code goes in the 'Visiblechanged' event:</p>
  
  <pre><code>if(ylc.ShowDialog() == DialogResult.OK)
  {
     this.lblSomeText.Text = ylc.PublicPropertyValue
  }
  </code></pre>