Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use ShowDialog instead of Show.</p> <pre><code>inm.ShowDialog(); </code></pre> <p>that will stop Form1 code till Form2 is closed. Once the form is closed you can read the name variable from it.</p> <pre><code>_nameProcessed = inm.name; </code></pre> <p>The final code would be:</p> <pre><code>private void showdial() { InputName inm = new InputName(); inm.ShowDialog(); _nameProcessed = inm.name; } </code></pre> <p><strong>EDIT</strong> for second problem: Buttons have a property named "DialogResult". Set the "OK" button to OK and "Cancel" one to Cancel. On the code you just need a small IF and change function to return a bool:</p> <pre><code>private bool showdial() { InputName inm = new InputName(); if (inm.ShowDialog() != System.Windows.Forms.DialogResult.OK) return false; _nameProcessed = inm.name; return true; } </code></pre> <p>Then at the button click</p> <pre><code>private void btnGetSomething_Click(object sender, EventArgs e) { if(!showdial()) return; //some more functionalities in this function!!! } </code></pre> <p><strong>EDIT 2</strong> -- Add this line 'this.Close()':</p> <pre><code>this.DialogResult = System.Windows.Forms.DialogResult.OK; </code></pre> <p>Making the final code:</p> <pre><code>private void btnOkay_Click(object sender, EventArgs e) { //string name; name = tbxName.Text; Form1 ict = new Form1(); if (name == "") { MessageBox.Show("Please Enter Your Name!"); } else { ict._nameProcessed = name; this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload