Solved

vb.net child form

Posted on 2004-09-28
6
835 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 88
scoresIncreasing challenge 10 57
wordsWithout 49 79
Program to display an alert on Windows Toolbar 2 65
A short article about a problem I had getting the GPS LocationListener working.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now