dogdaynoon
New member
- Joined
- Apr 10, 2015
- Messages
- 2
- Programming Experience
- Beginner
Hopefully this will be easy for someone here.
I am wanting to pass and append a string into a textbox in a new windows form.
Currently I am trying the following...
in first form on a button press do this:
in second form I am doing like this
I am receiving the following error:
An unhandled exception of type 'System.NullReferenceException' occurred in ProgramName.exe
Additional information: Object reference not set to an instance of an object.
Troubleshooting tips:
Check to determine if the object is null before calling the method.
Use the "new" keyword to create and object instance.
Get general help about this exception.
I am wanting to pass and append a string into a textbox in a new windows form.
Currently I am trying the following...
in first form on a button press do this:
C#:
NewForm newForm = new NewForm("text");
newForm.Show();
in second form I am doing like this
C#:
public NewForm(string textFromForm1)
{
if(textFromForm1 != null)
{
this.NameOfTextBoxInForm2.AppendText(textFromForm1);
} else
{
MessageBox.Show("No text received!");
}
}
I am receiving the following error:
An unhandled exception of type 'System.NullReferenceException' occurred in ProgramName.exe
Additional information: Object reference not set to an instance of an object.
Troubleshooting tips:
Check to determine if the object is null before calling the method.
Use the "new" keyword to create and object instance.
Get general help about this exception.