mdiParent problem

B

Ben dotNet

FormA is the mdiParent
FormB is the child
FormC is the Form that is used to open FormB

How do I open FormB from FormC (that is not a child) so that it it's
mdiParent is FormA?

Thanks,
--Ben
 
K

Ken Tucker [MVP]

Hi,

From FormC try something like that.

Dim frm as new FormB
frm.MdiParent = Me.MdiParent
frm.Show

Ken
 
B

Ben dotNet

Very good thinking, but my FormC is not a Child of any mdiParent. It's more
like a custom Open File Dialog Form (non-modal).

--Ben
 
H

Herfried K. Wagner [MVP]

* "Ken Tucker said:
From FormC try something like that.

Dim frm as new FormB
frm.MdiParent = Me.MdiParent
frm.Show

'FormC' is /not/ a child ;-).
 
J

Juan Romero

Create a custom property on FormC that will contain the reference to the
parent (FormA). Modify the Constructor of FormC (New()) to take this value
as a parameter and set it. Then when you create FormB, set the parent to
that.
Example:

In FormC:
Sub New(ByRef MainParent as form)
me.ParentToSet = MainParent 'your custom property
End Sub

Sub OpenFormB()
Dim x as new FormB
x.mdiParent = me.ParentToSet
x.show()
Sub

or you can also modify FormB's constructor and pass the reference as a
parameter:

In FormB:
Sub New(ByRef MainParent as form)
me.mdiParent = MainParent
End Sub

In FormC
Sub OpenFormB()
Dim x as new FormB(me.ParentToSet)
x.show()
Sub

Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top