Hi All,
I am having this issue and don't really know a good way to overcome it. I have a main form. With a click of a button another form is created. For the example let's just say it has a simple text box. You type whatever you want in it.
My problem arises is how do I get the string from that child class to the calling class.
private void OpenForm_Click(object sender, EventArgs e)
{
this.ChildClass = new TextboxForm();
this.ChildClass.Show();
//Before the class loses scope and gets GC'ed I can call a property of the child class
string strTemp = this.ChildClass.UserString;
//But the problem is after it shows the form it immediatly assigns the strTemp with null or "" because the user hasn't even had time to type something in the box.
}
So what I would like to know is a a good solution for when the child form closes it can somehow pipe back information to the parent class. I tried doing some research and a delegate kept popping in my head but through frustration couldn't get them working. So is a delegate a good solution for this or am I completely missing something.