My guess is you'd want to wait until Form2 is loaded before its controls are available (not null) to be able to change their properties, and that usually happens after the Form_Load event, which doesn't take place until you show the form (ShowDialog or SHow)
I think your best bet is to define a public property on Form2, say:
public string strTextBoxText;
then change your code to do the following:
Form2 form2=new Form2(); form2.strTextBoxText="The new Text"; form2.Show();
Then catch the Load Event for Form2, and inside it implement the following:
YousefPosted Apr 18, 2007, 7:22 PM
My guess is you'd want to wait until Form2 is loaded before its controls are available (not null) to be able to change their properties, and that usually happens after the Form_Load event, which doesn't take place until you show the form (ShowDialog or SHow)
I think your best bet is to define a public property on Form2, say:
public string strTextBoxText;
then change your code to do the following:
Form2 form2=new Form2();
form2.strTextBoxText="The new Text";
form2.Show();
Then catch the Load Event for Form2, and inside it implement the following:
Form2_Load(...)
{
TextBox.Text=strTextBoxText;
}
Hope this helps