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:

I'm not a huge fan of creating gigantic constructors. I usually limit the
arguments on a constructor to those absolutely necessary for the object to
function correctly. If the above example must have MyInt to work correctly,
I'd create an argument for it in the constructor, otherwise I'd leave it as
a property. Also, if you're need to update a control on the child form from
an exposed property you can do so quite easily so long as your object calls
the Initialize method on the form in the constructor (if you're using Visual
Studio).

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:

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:

Create a public property on the child form you access from the parent.

<snip>

>
I'm not a huge fan of creating gigantic constructors. I usually limit the
arguments on a constructor to those absolutely necessary for the object to
function correctly. If the above example must have MyInt to work correctly,
I'd create an argument for it in the constructor, otherwise I'd leave it as
a property. Also, if you're need to update a control on the child form from
an exposed property you can do so quite easily so long as your object calls
the Initialize method on the form in the constructor (if you're using Visual
Studio).

I'd also add that, if both forms require acess to a number of shared
values, it may be worthwhile creating an object which is passed (via a
parameterised constructor in the child form).
The advantage here is that - assuming the parent form wants to know
about values changed in the child - it has access to the object
'immediately' - i.e. without having to access parameters on the child
form.
I also am not a fan of exposing controls on child forms - much better
(IMHO) to expose a property which is of relevant type - but not of the
actual control type (e.g. a string property ratherthan a TextBox
propertyif the parent wants to set the child's textBox's .Text
property. This abstraction allows the child form to be changed (e.g.
to use a label instead of a textbox) without the need to change the
parent form at all.

Create a public property on the child form you access from the parent.

<snip>

>
I'm not a huge fan of creating gigantic constructors. I usually limit the
arguments on a constructor to those absolutely necessary for the object to
function correctly. If the above example must have MyInt to work correctly,
I'd create an argument for it in the constructor, otherwise I'd leave it as
a property. Also, if you're need to update a control on the child form from
an exposed property you can do so quite easily so long as your object calls
the Initialize method on the form in the constructor (if you're using Visual
Studio).

I'd also add that, if both forms require acess to a number of shared
values, it may be worthwhile creating an object which is passed (via a
parameterised constructor in the child form).
The advantage here is that - assuming the parent form wants to know
about values changed in the child - it has access to the object
'immediately' - i.e. without having to access parameters on the child
form.
I also am not a fan of exposing controls on child forms - much better
(IMHO) to expose a property which is of relevant type - but not of the
actual control type (e.g. a string property ratherthan a TextBox
propertyif the parent wants to set the child's textBox's .Text
property. This abstraction allows the child form to be changed (e.g.
to use a label instead of a textbox) without the need to change the
parent form at all.

>
It's just my personal opinion, but I do not like to use parameterized
form constructors. The only time I even use class constructors with
parameters is when I need to set up some overloads.

I prefer to pass data to another form via properties.

That's interesting. I wonder why it's a personal preference, except
for the fact that constructors are maybe more inflexible since they
are only run once, during instantiation, while properties can be set
and get anytime.