Solved

vb.net Mdi Forms

Posted on 2007-03-25
7
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 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