Home > DeveloperSection > Forums > How to pass value from one Windows Form to another Windows Form in C#
Andrew Watson
Andrew Watson

Total Post:39

Points:273
Posted on    December-21-2010 4:45 AM

 C# C# 
Ratings:


 2 Reply(s)
 2134  View(s)
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


Uttam Misra

Total Post:125

Points:897
Posted on    December-21-2010 4:51 AM


Awadhendra Tiwari

Total Post:126

Points:882
Posted on    January-21-2011 2:20 AM

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;
        }
}

Don't want to miss updates? Please click the below button!

Follow MindStick