HOW TO PASS VALUE FROM ONE WINDOWS FORM TO ANOTHER WINDOWS FORM IN C#

Andrew Watson

Total Post:39

Points:273
Posted by  Andrew Watson
C# 
C#
 2373  View(s)
Ratings:
Rate this:
Hello Everyone, here I have a problem in passing value from one windows form to another windows form.
If possible provide me any helpful link or code.
Thanks
  1. Awadhendra Tiwari

    Post:126

    Points:882
    Re: How to pass value from one Windows Form to another Windows Form in C#

    make a parametrize constructor in second form and pass values to that constructor as following example shows...

    class Form1 : Form
    {
            public void btn_click(object sender,EventArgs e)
            {
                    Form2 fr=new Form2("Awadhendra",21,"Allahabad");
                    fr.Show();
            }
    }

    class Form2 : Form
    {
            private string name,city;
            private int age;
            public Form2(string name,int age,string city)
            {
                    InitilizeComponent();
                    this.name=name;
                    this.age=age;
                    this.city=city;
            }
    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!