Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This example retrieves a value from a text box on a Windows Form and displays it in a text box on another form.
Example
In Form1.cs:
private Form2 otherForm;
private void GetOtherFormTextBox()
{
textBox1.Text = otherForm.TextBox1.Text;
}
In Form2.cs:
public TextBox TextBox1
{
get
{
return textBox1;
}
}
Compiling the Code
This example requires:
- Two forms named
Form1andForm2, each containing a TextBox control namedtextBox1.Form1should create an instance ofForm2and assign it tootherForm; GetOtherFormTextBox will copy the text inForm2'stextBox1toForm1'stextBox1.