I'd like to know how I go about passing two variables from one form to the next.
For example, I can pass a variable like this:
This demonstrates how to pass a variable to a form when the form is opened.
Then in the new form:
Since i want to pass two variables from two dateTime pickers I would like something like this:
Where i declare two parent values but that does not work...any help please
For example, I can pass a variable like this:
This demonstrates how to pass a variable to a form when the form is opened.
Code:
private void OpenForm_Click(object sender, System.EventArgs e)
{
// Get the value to be passed
string parentValue = this.UserResponse.Text;
// Create the child form and pass the value in the constructor
this.ChildForm = new ChildForm(parentValue);
// Show the form which will display the user's value.
this.ChildForm.Show();
}
Code:
public string ValueFromParent
{
set
{
this.ParentValue.Text = value;
}
}
Code:
private void OpenForm_Click(object sender, System.EventArgs e)
{
// Get the value to be passed
string parentValue = this.dateTimePicker1.Text;
string parentValue2 = this.dateTimePicker2.Text;
// Create the child form and pass the value in the constructor
this.ChildForm = new ChildForm(parentValue,parentValue2);
// Show the form which will display the user's value.
this.ChildForm.Show();
}
Comment