You were not passing the value of Form1.Textbox.Text to the Form2 instance object.
/****************************************/
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
internal string Form1TextBoxText
{
get
{
return textBox1.Text;
}
}
internal string Form2TextBoxText
{
set
{
textBox1.Text = value;
}
}
private void button1_Click(object sender, EventArgs e)
{
Form2 F2 = new Form2(this.textBox1.Text); // change made here
F2.ShowDialog();
}
}
/*****************************************************/
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
// added this new constructor.
public Form2(string text)
: this()
{
this.textBox1.Text = text;
}
Form1 F1 = (Form1)Application.OpenForms["Form1"];
private string Form1TextBoxText
{
set
{
textBox1.Text = value;
}
}
private void button1_Click(object sender, EventArgs e)
{
F1.Form2TextBoxText = textBox1.Text;
this.Close();
}
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = F1.Form1TextBoxText;
}
}
/**********************************************/
Mark the best replies as answers. "Fooling computers since 1971."