R
raylopez99
This thread is about how variables or parameters (including objects)
are passed between forms (namely, using parameterized constructors,
e.g., to pass an int between forms (e.g., a calling form and a called
dialog form) (see below).
My question is that though this works fine, and is consistent with
everything I learned in C++, is there a 'better' way to pass
information, including member variables, objects, and the like, other
than using a parametized constructor as below?
Just to clarify: I don't believe a global variable is a 'better' way,
so that way is excluded.
RL
====calling form, has this somewhere in an event trigger procedure
where you want to call the called form:
int kay = myClass.SomeProperty;
Form2MyWinForm myForm01 = new Form2MyWinForm(kay); //a
parametized constructor, since parameter int 'kay' is passed
myForm01.Show(); //shows the called form
====called form (dialog), has this parametized normal constructor:
public partial class Form2MyDialogBox : Form
{
int F2MDBint;
public Form2MyDialogBox(int j) //parameterized instance
constructor, takes an 'int', which is therefore passed from calling to
called form.
{
InitializeComponent();
F2MDBint = j;
}
///
are passed between forms (namely, using parameterized constructors,
e.g., to pass an int between forms (e.g., a calling form and a called
dialog form) (see below).
My question is that though this works fine, and is consistent with
everything I learned in C++, is there a 'better' way to pass
information, including member variables, objects, and the like, other
than using a parametized constructor as below?
Just to clarify: I don't believe a global variable is a 'better' way,
so that way is excluded.
RL
====calling form, has this somewhere in an event trigger procedure
where you want to call the called form:
int kay = myClass.SomeProperty;
Form2MyWinForm myForm01 = new Form2MyWinForm(kay); //a
parametized constructor, since parameter int 'kay' is passed
myForm01.Show(); //shows the called form
====called form (dialog), has this parametized normal constructor:
public partial class Form2MyDialogBox : Form
{
int F2MDBint;
public Form2MyDialogBox(int j) //parameterized instance
constructor, takes an 'int', which is therefore passed from calling to
called form.
{
InitializeComponent();
F2MDBint = j;
}
///