VB2010 - MDI Settings, child form not bound

hi all,

please can you have a look at my code.

basically when i click the button on form1 i want form2 to open but to be bound within form1 which is set as mdi = true

but when i click on the button form2 opens but it is free to travel outside of the form1, i.e. it does not apear to be bound by form1

any ideas?

 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form2.MdiParent = Me

    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Form2.MdiParent = Me.MdiParent
        Form2.Show()
    End Sub


End Class

Open in new window

LVL 1
bede123Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonMiddle School Assistant TeacherCommented:
Change line #8 so you have "Me" instead of "Me.MdiParent":
Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        Form2.MdiParent = Me
        Form2.Show()
    End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bede123Author Commented:
yep you got. thanks very much.
0
Mike TomlinsonMiddle School Assistant TeacherCommented:
*This fixed it because when you had "Me.MdiParent", you were assigning NOTHING as the MdiParent of Form2, since Form1 does not have an MdiParent.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.