Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem showing Child Form

Status
Not open for further replies.

wraygun

Programmer
Dec 9, 2001
272
US
I have MDI form entitled Form1, A childform entitled frmRectRect and another form shown modally entitled Form2.

I would like to display frmRectRect as a child of Form1 by clicking on a button on Form2.

I have the following sub in Form1:
Code:
Sub ShowMdiChildWindow()

        Dim frm As New frmRectRect()
        frm.MdiParent = Me
        frm.WindowState = FormWindowState.Maximized
        frm.Show()
End Sub
This works fine if I call it from Form1, but from Form2 it's not working.

This is the code I'm attempting to use from Form2:
Code:
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm As New Form1()
        frm.ShowMdiChildWindow()
        Me.Hide()

    End Sub
At a loss,
Harold




***You can't change your past, but you can change your future***
 
If you want to access your forms from anywhere in your app then it is much better to declare them in a module.

You need to declare the items in the module first


Public frm As frmRectRect
Public frm1 as Form1
Public Frm2 As Form2
Public Frm3 As Form3

Sub Main()
Frm1.ShowDialog()
End Sub


Then you can access your forms anywhere

frm = New frmRectRect()
frm.MdiParent = frm1
frm.WindowState = FormWindowState.Maximized
frm.Show()


You need to change your startup object in your project first.

Right click on your project and go to properties. There you will see a drowdown for startup object. Change it to sub main.

DotNetDoc
M.C.S.D.
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb
-----------------------------------
If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top