Hi John,
Kevin has provided you the general solution. Some additional info:
1. Since all the control references of a form is declared as private by
default, although the first form has the reference of second form, it can
not manipulate the controls on the second form yet. You have several
options if you want to manipulate certain control on second form. For
example, you may encapsulate the code you want to execute in a public
method of second form, since this method is a member method of second form
class, it can manipulate the privates fields/properties of second form
without any problem. And since it is public, the first form can call this
method now. Another option is just changing the modifier of the control
reference you want to access from "private" to "public". However, this will
break the encapsulation concept of OOP, so it is only convinient when you
want to get a lot of control over that control, which is not easy to
encapsulate as public methods.
2. If you want to get the opposite done, that is, calling the first form
from the new created second form, the normal solution is passing the first
form reference in second form's constructor. You may explicitly create a
customized constructor of second form, which accept a parameter of type
first_form, then in the constructor, you may again store the parameter
passed in as a private field of type first_form for later reference. Sample
logic like this:
Second_Form form=new Second_Form(this);
form.Show();
public class Second_Form
{
private First_Form m_firstform=null;
public Second_Form(First_Form f)
{
m_firstform=f;
}
...
}
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.