I have a main form called MainWindow and a second form called NewTitleWindow. On the MainWindow form I have a textbox control called SearchTerm. When a user clicks a button on this form it opens the NewTitleWindow and I want to be able to access the value inside the SearchTerm textbox but I keep getting the error: "Object reference not set to an instance of an object." I've read multiple tutorials online and this is the code I've put together...

On the MainWindow form I call the NewTitleWindow form with:

NewTitleWindow myForm = new NewTitleWindow();
myForm.ShowDialog(this);

On the NewTitleWindow form I have:

String search = ((MainWindow)this.ParentForm).SearchTerm.Text;

and that is the line at which I get the error.

If anyone could tell me how to fix this I'd love them forever

Thanks in advance!