Solved

vb.net child form

Posted on 2004-09-28
6
845 Views
Last Modified: 2012-06-27
I havew a mdiparent form and I want to make all other forms inside that parent form. I used this before

dim form2 as new form2
form2.mdiparent = mdiparent.activeform
form2.show



the problem is lets say I have 3 forms
mdiparent, form2, form3

and I have form2 open inside using the above code. Now I have a button on form2 that will open form3 how do u do that. It seems to act wierd and I understand why. The reason is because the mdiparent activeform at the time is form2.

what is the right way to do this


0
Comment
Question by:hogan9111
  • 3
  • 2
6 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 35 total points
ID: 12173486
From mdiParent:

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f2 As New Form2
        f2.MdiParent = Me
        f2.Show()
    End Sub

From Form2:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim f3 As New Form3
        f3.MdiParent = Me.MdiParent
        f3.Show()
    End Sub
0
 
LVL 4

Expert Comment

by:ndegioia
ID: 12179388
Idle Mind is correct.  All you have to do is identify which form you wan to be its parent.  In the case above it is done with the  fe.Mdiparent = Me.Mdiparent  The Me.Mdiparent is placing the scope back to the mdi parent form and not form2.

Hope this helps.
0
 

Author Comment

by:hogan9111
ID: 12217603
could you also do this

  Dim Form3As New Form3
  Form3.MdiParent = Me.MdiParent
  Form3.Show()
if not why


wouldn't me represent the current form open??
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12217733
Me represents the current encompassing class.  It is possible to execute code in a form via events without that form having the focus.

In this case, that would work if the MdiParent property was properly set for Form2.

~IM
0
 

Author Comment

by:hogan9111
ID: 12289417
ok but when I have form2 maximize and I go to call form3 that is not suppose to be it makes it maximize, I have the form setting for fixed, centerscreen. Now if I make form2 not maximize and call for 3 it works properly. What can I do
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 12289458
That is a "by design issue" with MDI child forms that you just have to live with.  If one MDI child is maximized, then all MDI children are maximized.  Likewise, if one MDI form is "restored" (not maximized) then all MDI children are restored.

Sorry,

Idle_Mind
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Plain Text Editor for iPad 6 105
Generate Unique ID in VB.NET 21 99
Why is initMap returning "not a function" error. 3 64
batch file or script 4 47
This article will show, step by step, how to integrate R code into a R Sweave document
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question