C# Programming
01-29-2010, 12:45 AM
I have a problem...
public delegate MyDelegate()
class MDIParent
{
public event MyDelegate myEvent;
public MDIParent() //Constructor
{
// Create and open MDIChild from MDIParent Constructor
MDIChild mdiForm = new (MDIChild())
}
Class MDIChild
{
public MDIChild //Constructor
{
((MDIParent)this.MdiParent).myEvent += new MyDelegate(myPriveteMethod);
}
}
Well, as you can see, I
- Auntomatcally create a MDIChild from MDIParent constructor
- In the MDIChild constructor I try to suscribe to an MDIParent event
It gives me a SystemNullException. It perfectly suscribes if I do it OUTSIDE the MDIChildForm constructor. I suppose it is becouse parent form is not still initialized (child is created form INSIDE parent's constructor).
I need to open MDIChild from the begginig, and suscribe to event at the begginning, too. Any workaround to do this without using the constructor
Thanks!
public delegate MyDelegate()
class MDIParent
{
public event MyDelegate myEvent;
public MDIParent() //Constructor
{
// Create and open MDIChild from MDIParent Constructor
MDIChild mdiForm = new (MDIChild())
}
Class MDIChild
{
public MDIChild //Constructor
{
((MDIParent)this.MdiParent).myEvent += new MyDelegate(myPriveteMethod);
}
}
Well, as you can see, I
- Auntomatcally create a MDIChild from MDIParent constructor
- In the MDIChild constructor I try to suscribe to an MDIParent event
It gives me a SystemNullException. It perfectly suscribes if I do it OUTSIDE the MDIChildForm constructor. I suppose it is becouse parent form is not still initialized (child is created form INSIDE parent's constructor).
I need to open MDIChild from the begginig, and suscribe to event at the begginning, too. Any workaround to do this without using the constructor
Thanks!