public partial class frmInput : Form
{
public frmInput()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
//Set our variables from our input form
string firstName = this.tbFirstName.Text;
string lastName = this.tbLastName.Text;
string sample = this.tbSample.Text;
//Create an instance of the output form
frmOutput frmOut = new frmOutput();
//We set values through a property
frmOut.Sample = sample;
//We set values through a public method
frmOut.SetDisplayValues(firstName, lastName);
//We show the output form
frmOut.ShowDialog();
}
}
public partial class frmOutput : Form
{
private string sample;
//Getter / Setter for Sample
public string Sample
{
get
{
return sample;
}
set
{
sample = value;
//Set from property
this.tbSample.Text = this.sample;
}
}
public frmOutput()
{
InitializeComponent();
}
public void SetDisplayValues(string firstName, string lastName)
{
//Set from method
this.tbFirstName.Text = firstName;
this.tbLastName.Text = lastName;
}
}