Open/Close Forms VB.Net
-
Ok...I know there must be an easier way to do this....Has anyone created a windows form app using vb.net using an MDI and child forms? I am trying to open and close child forms. When I try to open or unhide (i have tried both ways) a new child form I get no results. Nothing happens, just my mdi form appears empty with no child forms. Can anyone lend their assistance? Thanks
-
Ok...I know there must be an easier way to do this....Has anyone created a windows form app using vb.net using an MDI and child forms? I am trying to open and close child forms. When I try to open or unhide (i have tried both ways) a new child form I get no results. Nothing happens, just my mdi form appears empty with no child forms. Can anyone lend their assistance? Thanks
Can you post some sample code? Just the body where you open up the child forms should do the trick Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]
-
Can you post some sample code? Just the body where you open up the child forms should do the trick Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]
Here is the code.... If Not IsNothing(frmChaindata) AndAlso Not frmChaindata.IsDisposed Then 'form exists just show it and bring it to front frmChaindata.BringToFront() frmChaindata.Focus() frmChaindata.WindowState = FormWindowState.Normal Else Me.Cursor = System.Windows.Forms.Cursors.WaitCursor mdiMain.IsMdiContainer = True frmChaindata = New ChainData frmChaindata.MdiParent = mdiMain frmChaindata.Show() Me.Hide() 'mdiMain.ShowHideForms(frmChaindata) Me.Cursor = System.Windows.Forms.Cursors.Default End If When this code executes....nothing happens but the mdi form appearing with no child forms showing....weird....
-
Here is the code.... If Not IsNothing(frmChaindata) AndAlso Not frmChaindata.IsDisposed Then 'form exists just show it and bring it to front frmChaindata.BringToFront() frmChaindata.Focus() frmChaindata.WindowState = FormWindowState.Normal Else Me.Cursor = System.Windows.Forms.Cursors.WaitCursor mdiMain.IsMdiContainer = True frmChaindata = New ChainData frmChaindata.MdiParent = mdiMain frmChaindata.Show() Me.Hide() 'mdiMain.ShowHideForms(frmChaindata) Me.Cursor = System.Windows.Forms.Cursors.Default End If When this code executes....nothing happens but the mdi form appearing with no child forms showing....weird....
-
One of the articles I read said to Hide instead of close so I implemented it. It does 'hide' but I can't get the child form to show up when I call it from another child form.
-
Here is the code.... If Not IsNothing(frmChaindata) AndAlso Not frmChaindata.IsDisposed Then 'form exists just show it and bring it to front frmChaindata.BringToFront() frmChaindata.Focus() frmChaindata.WindowState = FormWindowState.Normal Else Me.Cursor = System.Windows.Forms.Cursors.WaitCursor mdiMain.IsMdiContainer = True frmChaindata = New ChainData frmChaindata.MdiParent = mdiMain frmChaindata.Show() Me.Hide() 'mdiMain.ShowHideForms(frmChaindata) Me.Cursor = System.Windows.Forms.Cursors.Default End If When this code executes....nothing happens but the mdi form appearing with no child forms showing....weird....
What is Me in this case? What happens if you take out the Me.Hide() statement? Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]
-
What is Me in this case? What happens if you take out the Me.Hide() statement? Jared Parsons jaredp@beanseed.org http://jaredparsons.blogspot.com/[^]
-
I agree that the me.hide seems strange but I think it is even more important that they are not saying frmChaindata.show() in the if part of the if/else statement! -- modified at 9:02 Friday 12th May, 2006
The "me" in this case is the first child form (child1). Because I am attempting to call one child from another. I am hiding the child1 form and trying to show the second child form. I tried adding the show, but no luck. In the else part of the if statement I am calling the .show method and it didn't work there either. Still working on it.....
-
The "me" in this case is the first child form (child1). Because I am attempting to call one child from another. I am hiding the child1 form and trying to show the second child form. I tried adding the show, but no luck. In the else part of the if statement I am calling the .show method and it didn't work there either. Still working on it.....
Throw this code in a MDI form and see if it helps out at all.
Private Sub MDIParent1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ChildForm1 As New System.Windows.Forms.Form Dim btnButton1 As New Button Dim ChildForm2 As New System.Windows.Forms.Form Dim btnButton2 As New Button ChildForm1.Text = "Form1" ChildForm2.Text = "Form2" btnButton1.Text = "I Control 2" btnButton2.Text = "I Control 1" ChildForm1.MdiParent = Me ChildForm1.Controls.Add(btnButton1) ChildForm1.Show() ChildForm1.Name = "Form1" ChildForm2.MdiParent = Me ChildForm2.Controls.Add(btnButton2) ChildForm2.Show() ChildForm2.Name = "Form2" AddHandler btnButton1.Click, AddressOf button_click AddHandler btnButton2.Click, AddressOf button_click End Sub Sub button_click(ByVal sender As Object, ByVal e As EventArgs) For Each frm As Form In Me.MdiChildren If frm.Name <> sender.parent.Name Then If frm.Visible Then frm.Hide() Else frm.Show() End If End If Next End Sub