Please, do not do what Аslam Iqbal or Manivannan Shan are recommending: it if a bad idea to make any controls on your form public. The reason is simple: when you do that you ties the design of the two forms together - you cannot change form1 without checking that it will not affect form2. You also cannot re-use form2 from form3 because it may not have the same layout or purpose.
Instead, there are two ways to do it:
1) Treat form2 like you would a OpenFileDialog: Show it, wait for the user to press OK and the close form2 and fetch the value in form1. That's easy: Set up a public property which returns the value(s) in the same way the OpenFileDialog supplies FileName
public string Value
{
get { return textboxUserInputTo.Text; }
set { textboxUserInputTo.Text = value; }
Then display your form with
form2 f2 = new form2();
if (f2.ShowDialog() == DialogResult.OK)
{
string s = f2.Value;
...
}
2) Set up an event in form2 which says "I have a value for you".
public event EventHandler Changed;
protected virtual void OnChanged(EventArgs e)
{
EventHandler eh = Changed;
if (eh != null)
{
eh(this, e);
}
}
private void DoSomethingToChangeData()
{
OnChanged(null);
}
Form1 then subscribes to the event.
private void ShowChildForm()
{
form2 f2 = new form2();
f2.Change += new form2.ChangeHandler(Changed);
f2.Show();
}
private void Changed(object sender, EventArgs e)
{
form2 f2 = sender as form2;
string s = f2.Value;
}