how to pass a "this" pointer in C#
Posted on 2009-02-22
Sure this is easy but Im stuck Ive migrated from C++ to C# and cant seem to pass the "this" pointer to an object. heres the setup
theres form1 derrived off Form, in form1 I create 4 objects, each object basically sets up information supplied by a user so a chart can be created thats it. When the user is finished in the object they press a button to build a chart.
I have two scenarios, either I return somehow to form1 and create the charts there as I can see the created objects anyhow from form1, and that is my prefered solution, or I can build the charts from within each object. Whatever I think of as a solution Im left with sending in a "this" pointer to the objects as a paramerer to the constructor when I am creating them. So whateve route I take I need "access" to form1. I can get the "this" pointer in no probs but I cant create a "type" Form1 I can only create a "type" Form, ie the baseclass.
I cant fathom how to see the type Form1 so I can return via a function call to form 1 when I click the button. Ive messed with the using directives but I cant see the form1 namespace for form1 no matter what I try and do within the object class.
There are 2 projects each with a different namespace, form1 is dependent on the object class. I really dont care what the settings need to be like as long as I can see form1 or you say, NO dont do it like that , do it like this? How do I proceed, cheers