how to access a variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
* "=?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

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'.
 
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.
 
Back
Top