I have two forms form1 and form2 and I want to transfer the value from form2 to form1. Form1 has a textbox where I want the value from Form2 Form2 has a button on its click the value gets from textbox on form2 to the textbox on form1
Here is my code :
Form2.cs
private Form1 HandleToForm2;
public Form2(Form1 frmHandle2)
{
HandleToForm2 = frmHandle2;
InitializeComponent();
}
private void update_Click(object sender, EventArgs e)
{
HandleToForm2.WriteToTextBox2(textBox2.Text);
this.Hide();
}
Form1.cs
public void WriteToTextBox2(string inputText1)
{
this.textBox8.Text = inputText1;
}
Dont know why its throwing NullReference Exception "Object not set to an instance of an object
HandleToForm2.WriteToTextBox2(textBox2.Text); //this line throws this exception
Thanks in advance :-)
HandleToForm2ortextBox2is null - use the debugger to find out which. - Hans Kesting