G Guest Jun 28, 2004 #1 hi i want to access a variables from form1 to form2 how should i declare on form1 and how can i get those values on form2
hi i want to access a variables from form1 to form2 how should i declare on form1 and how can i get those values on form2
H Herfried K. Wagner [MVP] Jun 28, 2004 #2 * "=?Utf-8?B?cnQ=?= said: hi i want to access a variables from form1 to form2 how should i declare on form1 and how can i get those values on form2 Click to expand... You will have to pass a reference to your 'Form1' to 'Form2'. If you are instantiating 'Form1' inside 'Form2', you could add a property of type 'Form1' to your 'Form2' and set this property to your instance of 'Form2'.
* "=?Utf-8?B?cnQ=?= said: hi i want to access a variables from form1 to form2 how should i declare on form1 and how can i get those values on form2 Click to expand... You will have to pass a reference to your 'Form1' to 'Form2'. If you are instantiating 'Form1' inside 'Form2', you could add a property of type 'Form1' to your 'Form2' and set this property to your instance of 'Form2'.
G Guest Jun 28, 2004 #3 Hi, You can do the same as under: In the form2, create an object of Form1 class. Form1 f = new Form1(); MessageBox.Show(f.Property); Alternately, the method suggested by Herfried is a better way.
Hi, You can do the same as under: In the form2, create an object of Form1 class. Form1 f = new Form1(); MessageBox.Show(f.Property); Alternately, the method suggested by Herfried is a better way.