C# Transfering text from one form to another....

Mar 23 2010 7:28 PM

I have a problem with some code, the first bit of code works fine the data is populated to the open form "testform" textbox1 from the contents of textbox1 on another form say customers form.

testform form1 = (testform)Application.OpenForms["testform"];
form1.Controls["textBox1"].Text = this.textBox1.Text;
Yet this code below which populates the same data to another form already open "bulkitemloadrequestform" throws the error "Object reference not set to an instance of the object"
bulkitemloadrequestform
form2 = (bulkitemloadrequestform)Application.OpenForms["bulkitemloadrequestform"];
form2.Controls[
"textBox5"].Text = this.textBox1.Text;
I can't seem to workout why this problem is occuring?
Help much appreciated.
 
 
 
 

Answers (3)