How Can I Show a Windows form by clicking a Button

talukdarmanoj

Member
Joined
Sep 26, 2007
Messages
6
Programming Experience
Beginner
I used the following code to diaplay the Form2 by Clicking a Button of Form1 both are childform but it does not work, anyone can help me ?

VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim frm As New Form2
        frm.MdiParent = MDIParentMain
        frm.Show()

    End Sub
 
Last edited by a moderator:
What do you mean "does not work"? Is there an error or doesn't anything happen?
 
Then it must be your MDIParentMain reference that is wrong. It sounds as you are referring to a default form, when the parent perhaps isn't the default form? Anyway a quickfix is to just refer to the same mdiparent your current child have:
frm.MdiParent = me.MdiParent
 
Back
Top