Originally posted by Nunu
you should use events.
In your second form you declare
Code:
public delegate void MyUpdateEventHandler(string msg);
public event MyUpdateEventHandler MyUpdateEvent;
// in the buttonclick method you add
if(MyUpdateEvent != null)
{
MyUpdateEvent(myTextBox.Text);
}
Code:
MySecondForm f = new MySecondForm(); f.MyUpdateEventHandler += (pressing TAB TAB in visual studio will auto-generate a method) f.Show();
In that generated method you must update your mainForm. However you'll have to use delegates and Control.Invoke for threadsafety.
Hope this helps
Regards
W.
Leave a comment: