Circular Reference Issue

Hi,

I have a situation where I have 1 solution and multiple projects underneath so that I can maintain seperate dll's for different reasons.

I have an MDI Parent form in one project and in another are all the forms that I want to instantiate as my MDI Children.

In my MDI Parent project I reference my project that has my MDI Children Forms. This is needed so that in the parent I can cast a new form of my child type and then call .Show().

This works great as expected. The problem I'm having is in my child mdi forms I need to call a method that belongs to my Parent MDI form. This method I have created as public but I have no way to reference it that I can find. I can call Form myForm = this.MDIParent; - but the only methods available are to Form and not my specific Form. I can't cast it to my Parent Form type as I don't have a reference to it because it is in a seperate project. I can't add the parent project reference in solution explorer - it complains that it would be a circular reference.

If I move my child forms into the main parent forms project - there is no problem casting the this.MDIParent to my parent form custom form type and that allows me to get at my public method.

I can't figure this out, but surely you must be able to do it using seperate projects. It don't want my children in the exe build I want them in seperate dll's so I can use the trickle down approach of loading them off a webserver.

thanks

[1456 byte] By [codefund.com] at [2007-12-16]
# 1
Actually - there is another problem I am running into here as well. It won't let me reference the MDIParent project because it is an exe not a dll - if anyone has any ideas it would be appreciated. For now I've copied all my children forms into the main project and building it all as one big exe. yikes....

thanks
Mike

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
I would setup an Event in your child forms that (before you call .Show for your new child form) you can have your parent form handle the event (for all child forms)

HTH

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
Hi Erik,

Thank you for your reply. I am not sure exactly what you mean by setting up an event in my child forms. What sort of event would it be and what would it do?

I'm sorry, but I'm unclear what this would do to help my issue.

Thanks
Mike

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
something like this...

<b>child form</b>

Public Class MyChildForm

...

Public Event SomethingHappened(ByVal sender As Object, ByVal e As EventArgs)

Private Sub DoingSomething()
RaiseEvent SomethingHappened(Me, New EventArgs())
End Sub

End Class

<b>parent form</b>

Public Class MyParentForm

...

Private Sub AddNewChild()
Dim Temp As New MyChildForm()
...
AddHandler Temp.SomethingHappened, AddressOf SomethingHappenedHandler
...
Temp.Show()
End Sub

Private Sub SomethingHappenedHandler(ByVal sender As Object, ByVal e As EventArgs)
'call some code
End Sub

End Class

Hope that helps! :)

codefund.com at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...