Solved

vb.net child form

Posted on 2004-09-28
6
838 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

808 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