Passing Variable Between 3 Forms












-1















I am trying to pass a couple variables between 3 separate forms. Form 1 is where each player (2 players) picks their name and type. It then sets player 1 variables into the second form and player 2 variables into the third form.



 private void button_player2Ready_Click(object sender, EventArgs e)
{
p2_name = textBox_P2.Text;


if (p2_name.Length > 0 && p2_type != null)
{
foreach (Control cont in groupBox_p2.Controls)
{
cont.Enabled = false;

}
player2Ready = true;

if (player1Ready == true && player2Ready == true)
{
Form1 firstForm = new Form1();
Form2 secondForm = new Form2();
Form3 thirdForm = new Form3();

//thirdForm.p2_name = "hello";
thirdForm.p2_type = p2_type;
thirdForm.p2_name = p2_name;



secondForm.p1_name = p1_name;

secondForm.p1_type = p1_type;



this.Hide();
secondForm.Show();



}
}
else
{
MessageBox.Show("Error: You have not selected a name or type...");

}

}
}


The second form works fine and player 1's name is displayed in the label but I believe this is causing problems when going to 3rd form as it is resetting the name of the third form because of this " Form3 thirdForm = new Form3();"



      public string p1_name { get; set; }


public string p1_type { get; set; }



public string word4player2;

public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
label1.Text = $"{p1_name} choose your opponents word...";

}

private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p1Word.Text.Contains(" "))
{
word4player2 = textbox_p1Word.Text;
Form1 firstForm = new Form1();
Form2 currentForm = new Form2();
Form3 thirdForm = new Form3();

thirdForm.Show();
Hide();


}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{

Application.Exit();
}
}


This is my third form which is supposed to display player 2's name. The form opens with no errors but the spot where the name goes is blank.



    public string p2_name { get; set; }


public string p2_type { get; set; }

public string word4player2;

public Form3()
{
InitializeComponent();
}


private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p2Word.Text.Contains(" "))
{
word4player2 = textbox_p2Word.Text;
}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{
Application.Exit();
}

private void Form3_Load(object sender, EventArgs e)
{
label1.Text = $"{p2_name} choose your opponents word...";
}


Any help would be great!










share|improve this question


















  • 4





    Possible duplicate of Communicate between two windows forms in C# and tens of thousands of others

    – Make StackOverflow Good Again
    Jan 2 at 23:53


















-1















I am trying to pass a couple variables between 3 separate forms. Form 1 is where each player (2 players) picks their name and type. It then sets player 1 variables into the second form and player 2 variables into the third form.



 private void button_player2Ready_Click(object sender, EventArgs e)
{
p2_name = textBox_P2.Text;


if (p2_name.Length > 0 && p2_type != null)
{
foreach (Control cont in groupBox_p2.Controls)
{
cont.Enabled = false;

}
player2Ready = true;

if (player1Ready == true && player2Ready == true)
{
Form1 firstForm = new Form1();
Form2 secondForm = new Form2();
Form3 thirdForm = new Form3();

//thirdForm.p2_name = "hello";
thirdForm.p2_type = p2_type;
thirdForm.p2_name = p2_name;



secondForm.p1_name = p1_name;

secondForm.p1_type = p1_type;



this.Hide();
secondForm.Show();



}
}
else
{
MessageBox.Show("Error: You have not selected a name or type...");

}

}
}


The second form works fine and player 1's name is displayed in the label but I believe this is causing problems when going to 3rd form as it is resetting the name of the third form because of this " Form3 thirdForm = new Form3();"



      public string p1_name { get; set; }


public string p1_type { get; set; }



public string word4player2;

public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
label1.Text = $"{p1_name} choose your opponents word...";

}

private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p1Word.Text.Contains(" "))
{
word4player2 = textbox_p1Word.Text;
Form1 firstForm = new Form1();
Form2 currentForm = new Form2();
Form3 thirdForm = new Form3();

thirdForm.Show();
Hide();


}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{

Application.Exit();
}
}


This is my third form which is supposed to display player 2's name. The form opens with no errors but the spot where the name goes is blank.



    public string p2_name { get; set; }


public string p2_type { get; set; }

public string word4player2;

public Form3()
{
InitializeComponent();
}


private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p2Word.Text.Contains(" "))
{
word4player2 = textbox_p2Word.Text;
}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{
Application.Exit();
}

private void Form3_Load(object sender, EventArgs e)
{
label1.Text = $"{p2_name} choose your opponents word...";
}


Any help would be great!










share|improve this question


















  • 4





    Possible duplicate of Communicate between two windows forms in C# and tens of thousands of others

    – Make StackOverflow Good Again
    Jan 2 at 23:53
















-1












-1








-1








I am trying to pass a couple variables between 3 separate forms. Form 1 is where each player (2 players) picks their name and type. It then sets player 1 variables into the second form and player 2 variables into the third form.



 private void button_player2Ready_Click(object sender, EventArgs e)
{
p2_name = textBox_P2.Text;


if (p2_name.Length > 0 && p2_type != null)
{
foreach (Control cont in groupBox_p2.Controls)
{
cont.Enabled = false;

}
player2Ready = true;

if (player1Ready == true && player2Ready == true)
{
Form1 firstForm = new Form1();
Form2 secondForm = new Form2();
Form3 thirdForm = new Form3();

//thirdForm.p2_name = "hello";
thirdForm.p2_type = p2_type;
thirdForm.p2_name = p2_name;



secondForm.p1_name = p1_name;

secondForm.p1_type = p1_type;



this.Hide();
secondForm.Show();



}
}
else
{
MessageBox.Show("Error: You have not selected a name or type...");

}

}
}


The second form works fine and player 1's name is displayed in the label but I believe this is causing problems when going to 3rd form as it is resetting the name of the third form because of this " Form3 thirdForm = new Form3();"



      public string p1_name { get; set; }


public string p1_type { get; set; }



public string word4player2;

public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
label1.Text = $"{p1_name} choose your opponents word...";

}

private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p1Word.Text.Contains(" "))
{
word4player2 = textbox_p1Word.Text;
Form1 firstForm = new Form1();
Form2 currentForm = new Form2();
Form3 thirdForm = new Form3();

thirdForm.Show();
Hide();


}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{

Application.Exit();
}
}


This is my third form which is supposed to display player 2's name. The form opens with no errors but the spot where the name goes is blank.



    public string p2_name { get; set; }


public string p2_type { get; set; }

public string word4player2;

public Form3()
{
InitializeComponent();
}


private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p2Word.Text.Contains(" "))
{
word4player2 = textbox_p2Word.Text;
}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{
Application.Exit();
}

private void Form3_Load(object sender, EventArgs e)
{
label1.Text = $"{p2_name} choose your opponents word...";
}


Any help would be great!










share|improve this question














I am trying to pass a couple variables between 3 separate forms. Form 1 is where each player (2 players) picks their name and type. It then sets player 1 variables into the second form and player 2 variables into the third form.



 private void button_player2Ready_Click(object sender, EventArgs e)
{
p2_name = textBox_P2.Text;


if (p2_name.Length > 0 && p2_type != null)
{
foreach (Control cont in groupBox_p2.Controls)
{
cont.Enabled = false;

}
player2Ready = true;

if (player1Ready == true && player2Ready == true)
{
Form1 firstForm = new Form1();
Form2 secondForm = new Form2();
Form3 thirdForm = new Form3();

//thirdForm.p2_name = "hello";
thirdForm.p2_type = p2_type;
thirdForm.p2_name = p2_name;



secondForm.p1_name = p1_name;

secondForm.p1_type = p1_type;



this.Hide();
secondForm.Show();



}
}
else
{
MessageBox.Show("Error: You have not selected a name or type...");

}

}
}


The second form works fine and player 1's name is displayed in the label but I believe this is causing problems when going to 3rd form as it is resetting the name of the third form because of this " Form3 thirdForm = new Form3();"



      public string p1_name { get; set; }


public string p1_type { get; set; }



public string word4player2;

public Form2()
{
InitializeComponent();
}

private void Form2_Load(object sender, EventArgs e)
{
label1.Text = $"{p1_name} choose your opponents word...";

}

private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p1Word.Text.Contains(" "))
{
word4player2 = textbox_p1Word.Text;
Form1 firstForm = new Form1();
Form2 currentForm = new Form2();
Form3 thirdForm = new Form3();

thirdForm.Show();
Hide();


}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{

Application.Exit();
}
}


This is my third form which is supposed to display player 2's name. The form opens with no errors but the spot where the name goes is blank.



    public string p2_name { get; set; }


public string p2_type { get; set; }

public string word4player2;

public Form3()
{
InitializeComponent();
}


private void button_submit_Click(object sender, EventArgs e)
{
if (!textbox_p2Word.Text.Contains(" "))
{
word4player2 = textbox_p2Word.Text;
}
else
{
MessageBox.Show("No Spaces allowed...");

}

}

private void Form2_FormClosed(object sender, FormClosedEventArgs e) //this is needed bc form1 is only hidden when form 2 opens thus not closing application properly
{
Application.Exit();
}

private void Form3_Load(object sender, EventArgs e)
{
label1.Text = $"{p2_name} choose your opponents word...";
}


Any help would be great!







c# visual-studio






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 2 at 23:45









ColinColin

82




82








  • 4





    Possible duplicate of Communicate between two windows forms in C# and tens of thousands of others

    – Make StackOverflow Good Again
    Jan 2 at 23:53
















  • 4





    Possible duplicate of Communicate between two windows forms in C# and tens of thousands of others

    – Make StackOverflow Good Again
    Jan 2 at 23:53










4




4





Possible duplicate of Communicate between two windows forms in C# and tens of thousands of others

– Make StackOverflow Good Again
Jan 2 at 23:53







Possible duplicate of Communicate between two windows forms in C# and tens of thousands of others

– Make StackOverflow Good Again
Jan 2 at 23:53














2 Answers
2






active

oldest

votes


















0














If you are not using Form3 directly from Form1, I would refrain from creating an instance of Form3 in Form1.



For passing the values to Form3, you can first pass it to Form2, and then in Form2, pass it to Form3 while invoking it.



In Form1



        Form2 secondForm = new Form2();
secondForm.p1_name = p1_name;
secondForm.p1_type = p1_type;

secondForm.Show();


In Form2



        Form3 thirdForm = new Form3();
thirdForm.p2_name = p2_name;
thirdForm.p2_type = p2_type;
thirdForm.Show();





share|improve this answer































    0














    You are setting up



    thirdForm.p2_type = p2_type;
    thirdForm.p2_name = p2_name;


    in your main form, and create another instance of Form3 in Form2 and showing that one. Note that every call for the constructor of an object create a new instance of that class.



    Form3 thirdForm = new Form3();


    line in Form1 creates an instance of Form3 type and sets up the type and the name properties. But this instance is not shown. You create another instance of Form3 in Form2's button_submit_Click method and show that without setting up the type and name values. If this form will be called only in Form2 then you should put two properties to Form2 class for p2_type and p2_name and organize the method as



    private void button_submit_Click(object sender, EventArgs e)
    {
    if (!textbox_p1Word.Text.Contains(" "))
    {
    word4player2 = textbox_p1Word.Text;
    Form1 firstForm = new Form1();
    Form2 currentForm = new Form2();
    Form3 thirdForm = new Form3();

    thirdForm.p2_type = p2_type;
    thirdForm.p2_name = p2_name;

    thirdForm.Show();
    Hide();
    }
    else
    {
    MessageBox.Show("No Spaces allowed...");

    }

    }


    and Form1



            if (player1Ready == true && player2Ready == true)
    {
    //Form1 firstForm = new Form1();//YOU DON'T NEED IT HERE
    Form2 secondForm = new Form2();
    //Form3 thirdForm = new Form3();//YOU DON'T NEED IT HERE


    secondForm.p2_type = p2_type;
    secondForm.p2_name = p2_name;

    secondForm.p1_name = p1_name;
    secondForm.p1_type = p1_type;

    this.Hide();
    secondForm.Show();
    }





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014644%2fpassing-variable-between-3-forms%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      If you are not using Form3 directly from Form1, I would refrain from creating an instance of Form3 in Form1.



      For passing the values to Form3, you can first pass it to Form2, and then in Form2, pass it to Form3 while invoking it.



      In Form1



              Form2 secondForm = new Form2();
      secondForm.p1_name = p1_name;
      secondForm.p1_type = p1_type;

      secondForm.Show();


      In Form2



              Form3 thirdForm = new Form3();
      thirdForm.p2_name = p2_name;
      thirdForm.p2_type = p2_type;
      thirdForm.Show();





      share|improve this answer




























        0














        If you are not using Form3 directly from Form1, I would refrain from creating an instance of Form3 in Form1.



        For passing the values to Form3, you can first pass it to Form2, and then in Form2, pass it to Form3 while invoking it.



        In Form1



                Form2 secondForm = new Form2();
        secondForm.p1_name = p1_name;
        secondForm.p1_type = p1_type;

        secondForm.Show();


        In Form2



                Form3 thirdForm = new Form3();
        thirdForm.p2_name = p2_name;
        thirdForm.p2_type = p2_type;
        thirdForm.Show();





        share|improve this answer


























          0












          0








          0







          If you are not using Form3 directly from Form1, I would refrain from creating an instance of Form3 in Form1.



          For passing the values to Form3, you can first pass it to Form2, and then in Form2, pass it to Form3 while invoking it.



          In Form1



                  Form2 secondForm = new Form2();
          secondForm.p1_name = p1_name;
          secondForm.p1_type = p1_type;

          secondForm.Show();


          In Form2



                  Form3 thirdForm = new Form3();
          thirdForm.p2_name = p2_name;
          thirdForm.p2_type = p2_type;
          thirdForm.Show();





          share|improve this answer













          If you are not using Form3 directly from Form1, I would refrain from creating an instance of Form3 in Form1.



          For passing the values to Form3, you can first pass it to Form2, and then in Form2, pass it to Form3 while invoking it.



          In Form1



                  Form2 secondForm = new Form2();
          secondForm.p1_name = p1_name;
          secondForm.p1_type = p1_type;

          secondForm.Show();


          In Form2



                  Form3 thirdForm = new Form3();
          thirdForm.p2_name = p2_name;
          thirdForm.p2_type = p2_type;
          thirdForm.Show();






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 23:52









          Anu ViswanAnu Viswan

          5,8052526




          5,8052526

























              0














              You are setting up



              thirdForm.p2_type = p2_type;
              thirdForm.p2_name = p2_name;


              in your main form, and create another instance of Form3 in Form2 and showing that one. Note that every call for the constructor of an object create a new instance of that class.



              Form3 thirdForm = new Form3();


              line in Form1 creates an instance of Form3 type and sets up the type and the name properties. But this instance is not shown. You create another instance of Form3 in Form2's button_submit_Click method and show that without setting up the type and name values. If this form will be called only in Form2 then you should put two properties to Form2 class for p2_type and p2_name and organize the method as



              private void button_submit_Click(object sender, EventArgs e)
              {
              if (!textbox_p1Word.Text.Contains(" "))
              {
              word4player2 = textbox_p1Word.Text;
              Form1 firstForm = new Form1();
              Form2 currentForm = new Form2();
              Form3 thirdForm = new Form3();

              thirdForm.p2_type = p2_type;
              thirdForm.p2_name = p2_name;

              thirdForm.Show();
              Hide();
              }
              else
              {
              MessageBox.Show("No Spaces allowed...");

              }

              }


              and Form1



                      if (player1Ready == true && player2Ready == true)
              {
              //Form1 firstForm = new Form1();//YOU DON'T NEED IT HERE
              Form2 secondForm = new Form2();
              //Form3 thirdForm = new Form3();//YOU DON'T NEED IT HERE


              secondForm.p2_type = p2_type;
              secondForm.p2_name = p2_name;

              secondForm.p1_name = p1_name;
              secondForm.p1_type = p1_type;

              this.Hide();
              secondForm.Show();
              }





              share|improve this answer




























                0














                You are setting up



                thirdForm.p2_type = p2_type;
                thirdForm.p2_name = p2_name;


                in your main form, and create another instance of Form3 in Form2 and showing that one. Note that every call for the constructor of an object create a new instance of that class.



                Form3 thirdForm = new Form3();


                line in Form1 creates an instance of Form3 type and sets up the type and the name properties. But this instance is not shown. You create another instance of Form3 in Form2's button_submit_Click method and show that without setting up the type and name values. If this form will be called only in Form2 then you should put two properties to Form2 class for p2_type and p2_name and organize the method as



                private void button_submit_Click(object sender, EventArgs e)
                {
                if (!textbox_p1Word.Text.Contains(" "))
                {
                word4player2 = textbox_p1Word.Text;
                Form1 firstForm = new Form1();
                Form2 currentForm = new Form2();
                Form3 thirdForm = new Form3();

                thirdForm.p2_type = p2_type;
                thirdForm.p2_name = p2_name;

                thirdForm.Show();
                Hide();
                }
                else
                {
                MessageBox.Show("No Spaces allowed...");

                }

                }


                and Form1



                        if (player1Ready == true && player2Ready == true)
                {
                //Form1 firstForm = new Form1();//YOU DON'T NEED IT HERE
                Form2 secondForm = new Form2();
                //Form3 thirdForm = new Form3();//YOU DON'T NEED IT HERE


                secondForm.p2_type = p2_type;
                secondForm.p2_name = p2_name;

                secondForm.p1_name = p1_name;
                secondForm.p1_type = p1_type;

                this.Hide();
                secondForm.Show();
                }





                share|improve this answer


























                  0












                  0








                  0







                  You are setting up



                  thirdForm.p2_type = p2_type;
                  thirdForm.p2_name = p2_name;


                  in your main form, and create another instance of Form3 in Form2 and showing that one. Note that every call for the constructor of an object create a new instance of that class.



                  Form3 thirdForm = new Form3();


                  line in Form1 creates an instance of Form3 type and sets up the type and the name properties. But this instance is not shown. You create another instance of Form3 in Form2's button_submit_Click method and show that without setting up the type and name values. If this form will be called only in Form2 then you should put two properties to Form2 class for p2_type and p2_name and organize the method as



                  private void button_submit_Click(object sender, EventArgs e)
                  {
                  if (!textbox_p1Word.Text.Contains(" "))
                  {
                  word4player2 = textbox_p1Word.Text;
                  Form1 firstForm = new Form1();
                  Form2 currentForm = new Form2();
                  Form3 thirdForm = new Form3();

                  thirdForm.p2_type = p2_type;
                  thirdForm.p2_name = p2_name;

                  thirdForm.Show();
                  Hide();
                  }
                  else
                  {
                  MessageBox.Show("No Spaces allowed...");

                  }

                  }


                  and Form1



                          if (player1Ready == true && player2Ready == true)
                  {
                  //Form1 firstForm = new Form1();//YOU DON'T NEED IT HERE
                  Form2 secondForm = new Form2();
                  //Form3 thirdForm = new Form3();//YOU DON'T NEED IT HERE


                  secondForm.p2_type = p2_type;
                  secondForm.p2_name = p2_name;

                  secondForm.p1_name = p1_name;
                  secondForm.p1_type = p1_type;

                  this.Hide();
                  secondForm.Show();
                  }





                  share|improve this answer













                  You are setting up



                  thirdForm.p2_type = p2_type;
                  thirdForm.p2_name = p2_name;


                  in your main form, and create another instance of Form3 in Form2 and showing that one. Note that every call for the constructor of an object create a new instance of that class.



                  Form3 thirdForm = new Form3();


                  line in Form1 creates an instance of Form3 type and sets up the type and the name properties. But this instance is not shown. You create another instance of Form3 in Form2's button_submit_Click method and show that without setting up the type and name values. If this form will be called only in Form2 then you should put two properties to Form2 class for p2_type and p2_name and organize the method as



                  private void button_submit_Click(object sender, EventArgs e)
                  {
                  if (!textbox_p1Word.Text.Contains(" "))
                  {
                  word4player2 = textbox_p1Word.Text;
                  Form1 firstForm = new Form1();
                  Form2 currentForm = new Form2();
                  Form3 thirdForm = new Form3();

                  thirdForm.p2_type = p2_type;
                  thirdForm.p2_name = p2_name;

                  thirdForm.Show();
                  Hide();
                  }
                  else
                  {
                  MessageBox.Show("No Spaces allowed...");

                  }

                  }


                  and Form1



                          if (player1Ready == true && player2Ready == true)
                  {
                  //Form1 firstForm = new Form1();//YOU DON'T NEED IT HERE
                  Form2 secondForm = new Form2();
                  //Form3 thirdForm = new Form3();//YOU DON'T NEED IT HERE


                  secondForm.p2_type = p2_type;
                  secondForm.p2_name = p2_name;

                  secondForm.p1_name = p1_name;
                  secondForm.p1_type = p1_type;

                  this.Hide();
                  secondForm.Show();
                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 3 at 0:02









                  GokhanGokhan

                  1244




                  1244






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014644%2fpassing-variable-between-3-forms%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Mossoró

                      Error while reading .h5 file using the rhdf5 package in R

                      Pushsharp Apns notification error: 'InvalidToken'