[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vb.net Mdi Forms

Posted on 2007-03-25
7
Medium Priority
?
408 Views
Last Modified: 2012-06-21
I have 2 forms - 1 mdiparent and other one mdichild
i open mdi child forms with the click event of a button in mdi parent
the coding which i am using to open mdichild is
in General delaration part
dim childform as form2
in button click
childform=new form2
childform.mdiparent=me
childform.bringtofront
childform.show()

My question is when the child form opens i am still able to see the button in form1 that is mdi parent
is there any solution for this the form1 button shouldnt be seen and i can open child form only through
button
0
Comment
Question by:pearlym
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 18787977
see my article http://www.emoreau.com/Entries/Articles/2003/09/Fun-with-MDI-forms.aspx in which you will find a method IsChildInMemory that will help you finding if the form is already visible or not (instead of hiding the button, you can prevent the form from appearing twice)..
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 18788553
You can also declare your childform as WithEvents and reset your variable when the form closes:

Public Class MdiParent

    Private WithEvents childForm As Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If childForm Is Nothing Then
            childForm = New Form2
            childForm.MdiParent = Me
        End If
        If childForm.WindowState = FormWindowState.Minimized Then
            childForm.WindowState = FormWindowState.Normal
        End If
        childForm.Show()
    End Sub

    Private Sub childForm_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles childForm.Closed
        childForm = Nothing
    End Sub

End Class
0
 

Author Comment

by:pearlym
ID: 18790719
Still the parent form button is visible even when the child form is active
I tried all the methods
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 18790777
So you just want the Button invisible while the form is active?

How about?...

Public Class MdiParent

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Visible = False
        Dim cf As New Form2
        cf.MdiParent = Me
        AddHandler cf.Closed, AddressOf cf_Closed
        cf.Show()
    End Sub

    Private Sub cf_Closed(ByVal sender As Object, ByVal e As System.EventArgs)
        Button1.Visible = True
    End Sub

End Class
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

829 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