Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Open/Close Forms VB.Net

Open/Close Forms VB.Net

Scheduled Pinned Locked Moved Visual Basic
csharpquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Duane L
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • D Duane L

      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

      J Offline
      J Offline
      Jared Parsons
      wrote on last edited by
      #2

      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/[^]

      D 1 Reply Last reply
      0
      • J Jared Parsons

        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/[^]

        D Offline
        D Offline
        Duane L
        wrote on last edited by
        #3

        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....

        J J 2 Replies Last reply
        0
        • D Duane L

          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....

          J Offline
          J Offline
          jwakeman
          wrote on last edited by
          #4

          why me.hide()?

          D 1 Reply Last reply
          0
          • J jwakeman

            why me.hide()?

            D Offline
            D Offline
            Duane L
            wrote on last edited by
            #5

            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.

            J 1 Reply Last reply
            0
            • D Duane L

              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.

              J Offline
              J Offline
              jwakeman
              wrote on last edited by
              #6

              I noticed that you do not show the form in the if part of your if/else. You only bring to front and focus and the form is not shown....weird -- modified at 18:02 Thursday 11th May, 2006

              1 Reply Last reply
              0
              • D Duane L

                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....

                J Offline
                J Offline
                Jared Parsons
                wrote on last edited by
                #7

                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/[^]

                J 1 Reply Last reply
                0
                • J Jared Parsons

                  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/[^]

                  J Offline
                  J Offline
                  jwakeman
                  wrote on last edited by
                  #8

                  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

                  D 1 Reply Last reply
                  0
                  • J jwakeman

                    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

                    D Offline
                    D Offline
                    Duane L
                    wrote on last edited by
                    #9

                    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.....

                    J 1 Reply Last reply
                    0
                    • D Duane L

                      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.....

                      J Offline
                      J Offline
                      jwakeman
                      wrote on last edited by
                      #10

                      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

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups