Getting values from another winform and passing it to current!

Posted by klm9971 on Stack Overflow See other posts from Stack Overflow or by klm9971
Published on 2010-12-31T16:39:22Z Indexed on 2010/12/31 16:54 UTC
Read the original article Hit count: 190

Filed under:
|

Hello:

I have 2 windows forms. The 1st one who gets active during start of the program has a button in which another 2nd windows form appears which has text field in which user type their name and HIT okay.

Now in the 1st form I have a variable name: nameproccessed which takes the name from the second form. But the problem is my button which is in the 1st form has more functions besides taking name, how can I stop the flow of the compiler to take first the name from the second form and then process the rest execution of the function???

Here is the snippet of my code:

//1st form
//Class1
 public string _nameProcessed = "";



private void btnGetSomething_Click(object sender, EventArgs e)
    {
         showdial();
         //some more functionalities in this function!!!
     }



private void showdial()
    {
      InputName inm = new InputName();
      inm.Show();

    }


//2nd form
//Class2
public string name;

private void btnEnterName_Click(object sender, EventArgs e)
    {

      name = tbxName.Text;
      Class1 ict = new Class1();
      ict._nameProcessed = name;
      this.Close();

    }

Now I want to take the 'name' from the second form put it on the _nameprocessed in the 1st form and then execute the rest of the function. How can I do that? Any help!

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms