Setting MDIParent of new form

G

Guest

Hello All,

Having an issue with setting the MDIParent of a new form.

I have a form called CMIMain. From this form a child form is opened called
Form1.

This is the code I use to set that up:

Dim Form1 As New Form1
Form1.MdiParent = Me
Form1.Show()

Now, from Form1 I want to open another form called Form2, and I want CMIMain
to be the parent of Form2 as well. I thought this code would work, but it
does not:

Dim Form2 As New Form2
Form2.MdiParent = CMIMain
Form2.Show()

The error I am getting says " 'CMIMain' is a type and cannot be used as an
expression"

Any suggestions?

Thanks!
 
D

Dave Hall

Try replacing the problem line with this one:

Form2.MdiParent = Me.MdiParent

Dave
 
C

Chris Jobson

I'm not well up with VB.NET, but I think:
Form2.MdiParent = MdiParent
or, equivalently,
Form2.MdiParent = Me.MdiParent
will work.

Chris Jobson
 
G

Guest

Thanks Dave and Chris.

That worked!


Chris Jobson said:
I'm not well up with VB.NET, but I think:
Form2.MdiParent = MdiParent
or, equivalently,
Form2.MdiParent = Me.MdiParent
will work.

Chris Jobson
 
Joined
May 6, 2012
Messages
1
Reaction score
0
Thanks

I just want to say thank you for the help. I found this site while searching for a solution to a similar problem
:congrats::congrats::congrats::adore:
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top