Jason,
I'm assuming that Form1 and Form2 are separate classes and can't "see" each
other??? If you try to connect the two, you get a cyclical error?
If so, I have two things to think about
:
1. If the forms provide similar tasks, you could create a base class to hold
the "global" or common items and then inherit each form from the baseform.
This would make the myString field automatically visible to both forms and
all others derived from baseform. (As long as myString is public or
protected.)
2. If it doesn't make sense to have a base class, you could use a delegate
in Global that fires off a method in Form2.cs that sets contents of
Global.myString to Form2.myString. The delegate method would be assigned by
Form2 when Form2 is created. Form1 would set Global.myString, then Form1
would call/invoke the delegate, which assignes Global.myString to
Form2.myString (because the method running is really
Form2.myStringFetchMethod.) Sounds a little complicated but it is really
pretty easy to do.
I prefer the base class technique when possible but delegation works great
too.
If you need some code examples, let me know and I'll work one up for you.
Charlie
:-)
"Jason Huang" <Ja************@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP09.phx.gbl...
Hi,
In Global.cs, I have public string myString="".
Another 2 forms are Form1.cs, Form2.cs.
How do I use the Global.cs' myString to store a string in Form1 and then
pass to Form2?
Thanks for help.
Jason