Solved

vb.net Mdi Forms

Posted on 2007-03-25
7
393 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
7 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 85

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 85

Accepted Solution

by:
Mike Tomlinson earned 50 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 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