Groups | Blog | Home
all groups > dotnet faqs > october 2004 >

dotnet faqs : Setting MDIParent of new form


ksedran
10/8/2004 1:23:05 PM
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!


--
Dave Hall
10/11/2004 4:52:04 PM
Try replacing the problem line with this one:

Form2.MdiParent = Me.MdiParent

Dave

[quoted text, click to view]

Chris Jobson
10/11/2004 9:52:58 PM
I'm not well up with VB.NET, but I think:
Form2.MdiParent = MdiParent
or, equivalently,
Form2.MdiParent = Me.MdiParent
will work.

Chris Jobson

[quoted text, click to view]

ksedran
10/12/2004 8:59:05 AM
Thanks Dave and Chris.

That worked!


[quoted text, click to view]
AddThis Social Bookmark Button