Results 1 to 3 of 3

Thread: How to close Forms in a MdiContainer (RESOLVED)

  1. #1

    Thread Starter
    Junior Member Novice's Avatar
    Join Date
    Nov 2003
    Location
    Stuttgart
    Posts
    19

    Question How to close Forms in a MdiContainer (RESOLVED)

    Hi there,

    i am a newbie in VB.NET and now I wanted to create something like a paint application. I have already made a Form containing a MdiContainer. I am able to open multiple new forms in this Container, but I'm unable to close them.

    I've used the following code in the Close_Click Event:

    Environment.Exit(0)

    and

    Close()

    but neither of them worked.

    Could you please help me out?

    Thanks
    Last edited by Novice; Nov 6th, 2003 at 09:49 AM.
    I know that I know nothing, therefore I know something.

  2. #2

    Thread Starter
    Junior Member Novice's Avatar
    Join Date
    Nov 2003
    Location
    Stuttgart
    Posts
    19
    Here is the code I'am using to open the new forms into my MdiContainer:

    Code:
        Private Sub MainMenuFileNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MainMenuFileNew.Click
            Dim frmNew As New Form2()
            frmNew.MdiParent = Me
            frmNew.Show()
        End Sub
    Now how do I get the new Forms closed?

    I don't think this is too much to a challenge, but too much for me.
    Please help
    I know that I know nothing, therefore I know something.

  3. #3

    Thread Starter
    Junior Member Novice's Avatar
    Join Date
    Nov 2003
    Location
    Stuttgart
    Posts
    19
    All right, I've got it.

    All you have to do is to write another 'Private Sub' which should be as follows:

    Code:
    Private Sub CloseSubForm()
            Dim ActiveView As frmSubForm = CType(Me.ActiveMdiChild, frmSubForm)
            ActiveView.Close()
        End Sub
    Then you have to write the following into your 'Button_Click'-Event:


    Code:
    CloseSubForm()
    Thanks anyway
    I know that I know nothing, therefore I know something.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width