   Passing Data Between Forms?
  here is my programs form structure: frmMain    |   frm2    frm3so frmMain creates new instances of frm2 and frm3, so I can send data from frmMain to frm2 and frm3 just fine.  Now here's the thing, I can't seem to figure out how to send data from frm2 to frmMain without creating a new instance of frmMain in frm2.  Any idea how I would do this?  Language C#.NET.   
  I don't know much about programming in C# for GUI, but, I assume that you could simply pass a reference of the original form to form 2 and transmit information (however you do that).Failing that, you could pass a function pointer (delegate in C#) to frm2 and then in that function store information in a seperate data structure.Or you could use PostMessage :)  (Although don't do that, its needlessly harder! I'm just joking hehe).... or sendMessage (ok, I'll stop ^^ ) - J   ;  I personally woudln't store a reference to the parent form in its child form. You should always try to make a form as independant as possible from the calling form. e.g. if you would create a new form frmMain2 and that form would call frm2, frm2 would be dependant on the structure and data of frmMain and thus not reusable by frmMain2.The better way IMHO is to have the child forms expose Public Events which are then handled by your main Form. When you raise the event in your child form you pass the needed data to the EventArgs parameter. Thus you can retrieve the data in the Parent form and act on it like you want to. This way your child forms become much more reusable.   ;  As the above poster said, definately use events/delegates for communication between forms.   ;  And properties for parent->child communication.   ;This might work.   ;Quote:Original post by MoeThis might work.What a horrible example. No wonder most people have rated it 1.   ;  What is so horrible about it?  It works....   ;Quote:Original post by MoeWhat is so horrible about it?  It works....That's what 60s Fortran programmers who wrote 10 pages long functions littered with gotos said when Dijkstra wrote his piece too.   ;  Actually, the example doesn't solve Darksuicide's problem. He said he wanted to send data from frm2 (or frm3) back to frmMain but without frm2 (or frm3)creating another frmMain, which is exactly what the example does.Darksuicide, suggest that you take some effort to learn the Window's messaging framework. This is one of the keys to the Windows programming framework and is intended by Microsoft for communication between the various windows (and of course other objects) in an application.I am not familiar with C# per se, but I know that the MFC app wizards make it very easy to create windows and define the messages for them.Joshua   