mdiParent problem

  • Thread starter Thread starter Ben dotNet
  • Start date Start date
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
 
Hi,

From FormC try something like that.

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

Ken
 
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
 
* "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 ;-).
 
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!
 
Back
Top