I would like to know how to communicate between forms using C#?
In Visual Basic it was easier since each form had it’s own instance, with C# it’s different.
In the Program Class I setup a public and static variable that hold my form:
public static FormProcess2 frmProcess2 = null;
Then in the Main method I create the form and show it up:
frmProcess2 = new FormProcess2();
frmProcess2.ShowDialog();
Now when that form loads, it load a background process that process XML files.
And the method that process all the files are in another class name XMLParser.
So in the BackgroundWorker doWork I load that method by:
XMLParser.Start();
Now the question is, how I can modify the frmProcess2 controls in the XMLParser class?
I wanted it to show what’s being updated by changing the label text as well as put some nice progress bar there.
But I can’t access the Program.frmProcess2 controls, all I can access is it’s defaults only…
well you can use delegates to communication between windows forms.
Check http://www.c-sharpcorner.com/uploadfile/mosessaur/winformsdelegates09042006094826am/winformsdelegates.aspx
For Delegates
EDIT
Check
Delegates (C# Programming Guide)
http://msdn.microsoft.com/en-us/library/ms173171%28VS.80%29.aspx
Creating Custom Delegates and Events in C#
http://www.csharphelp.com/2007/02/creating-custom-delegates-and-events-in-c/
Introduction to Delegates and Events
http://www.csharp-station.com/Tutorials/lesson14.aspx