c# .Net 3.5 visual studio 2008, windows xp
I have a main form in a project, given a specific set of circumstances another form is instantiated and displayed to the user:
Form frmT = new frmTargetFolder(expName, this);
frmT.Show();
As you can see, I am passing a reference to the new form from the current one. My question is, what do I have to do to a method so that it is exposed to the new form, the same for a variable?
I have tried defining the functions as public, but I can’t seem to access them, also I have written a Get and Set method for a variable, again how do I expose these functions and methods to other forms?
public void hit()
{
MessageBox.Show("hit it");
}
bool setOverRide
{
get
{
return OverRide;
}
set
{
OverRide = value;
}
}
The main form is called frmDataXfer and the form, form which I am trying to call the functions and methods of frmDataXfer is called frmTargetFolder, an instance of which is created in the frmDataXfer and referenced as frmT.
Thanks, R.
You need to store an instance of
frmDataXferas a field in thefrmTargetFolderclass, then call the methods on that instance.