title: Close dialog box and child form and pass result to main form
body: <p>I have C# windows form that open a child form, in it I have textbox, OK and Cancel buttons,  </p>
  
  <p>When user clicks OK I check the connection to the machine user entered in the textbox.<br>
  If connection is OK I want to close child form, if not show a Yes\No message asking if user still want to use the entered machine name.<br>
  If answer is Yes close the child form, if not just close the Yes\No question.  </p>
  
  <p>In the main form I’m checking the child dialog DialogResult but can't seems to make it work since this.Close pass Cancel result. Here is the code in the main form:</p>
  
  <pre><code>DialogResult result = SetServer.ShowDialog();
  if (result == DialogResult.OK)
  {
      // BLA
  }
  </code></pre>
  
  <p>Code on child form</p>
  
  <pre><code>if (!PingMachine(testmachine))
  {
      DialogResult dialogResult = MessageBox.Show(“No connection", "Check", 
      MessageBoxButtons.YesNo);
      if (dialogResult == DialogResult.Yes)
      {
          btnOK.DialogResult = DialogResult.OK;
      }
      else
      {
          btnOK.DialogResult = DialogResult.No;
      }
      this.Close();
  }
  </code></pre>