sharing variables/information between two forms

Background:
Visual c++ .net express 2005
windows xp


I have two forms, inside the same application. Form1 creates Form2, so I assume it is a "child" of some sort. Anyway, I am collecting data via rs232 in the main form (form1) and would like to pass that information to form2. I was looking for some function like "GetParent" to get a handle to the original or any other way that is typical to pass information between forms. I have tried to even compile an old c++ singleton class that I have to share the information, but it doesn't mix well with managed c++ (because of the static variables?) . Anyway, is there a "proper" way to handle this ? I don't really want an MDI type solution. I would like this to all be independent forms so that non pertinent forms can just be minimized or hidden when they aren't needed, as well as the ability to see both forms. Sample code would be most helpful! I'm pretty wet behind the ears on this, as I usually just do embedded C and VHDL.

Thanks!
fenriss_wolffAsked:
Who is Participating?
 
Knut HunstadCommented:
Since your form2 is created by form1, then form1 can store a pointer to form2 and call functions or set member variables for form2 directly. Whether form2 is a real "child" of form1 or not is something you define when you create form2. You could also send data to form2 as messages.
0
 
fenriss_wolffAuthor Commented:
I'm so new that I didn't even know you forms were inherited, and all I needed to do was create a set function with a pointer to my data that I want to pass from Form1 . Thx!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.