Unload a Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • V.Boomessh

    Unload a Form

    Hai
    can any one help me on this problem.

    I am new to VB.NET.

    I have 2 forms. (form1 and form2)

    On click of a button in form1 i want to show form2 and
    unload form1

    how can i accomplish it.

    V.Boomessh
  • Munsifali Rashid

    #2
    Re: Unload a Form

    As far as I know, when you call the close method of a form, it is unloaded.
    So, you would have something like the following:

    'Create an instance of the second form
    Dim MySecondForm As New Form2

    'Close (unload) this form
    Me.Close()

    'Show the second form
    MySecondForm.Sh ow()


    Hope this helps,

    Mun


    --
    Munsifali Rashid




    "V.Boomessh " <anonymous@disc ussions.microso ft.com> wrote in message
    news:096301c3d6 99$0b9ced80$a30 1280a@phx.gbl.. .[color=blue]
    > Hai
    > can any one help me on this problem.
    >
    > I am new to VB.NET.
    >
    > I have 2 forms. (form1 and form2)
    >
    > On click of a button in form1 i want to show form2 and
    > unload form1
    >
    > how can i accomplish it.
    >
    > V.Boomessh[/color]


    Comment

    • V.Boomessh

      #3
      Re: Unload a Form

      Hai,

      The code just ends the application and comes out. It is
      not solving the problem.

      regards,
      V.Boomessh
      [color=blue]
      >-----Original Message-----
      >As far as I know, when you call the close method of a[/color]
      form, it is unloaded.[color=blue]
      >So, you would have something like the following:
      >
      >'Create an instance of the second form
      >Dim MySecondForm As New Form2
      >
      >'Close (unload) this form
      >Me.Close()
      >
      >'Show the second form
      >MySecondForm.S how()
      >
      >
      >Hope this helps,
      >
      >Mun
      >
      >
      >--
      >Munsifali Rashid
      >http://www.munsplace.com/
      >
      >
      >
      >"V.Boomessh " <anonymous@disc ussions.microso ft.com> wrote[/color]
      in message[color=blue]
      >news:096301c3d 699$0b9ced80$a3 01280a@phx.gbl. ..[color=green]
      >> Hai
      >> can any one help me on this problem.
      >>
      >> I am new to VB.NET.
      >>
      >> I have 2 forms. (form1 and form2)
      >>
      >> On click of a button in form1 i want to show form2 and
      >> unload form1
      >>
      >> how can i accomplish it.
      >>
      >> V.Boomessh[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Cor

        #4
        Re: Unload a Form

        Hi V Boomessh,

        For this kind of problems is a active newsgroup
        Microsoft.publi c.dotnet.langua ges.vb
        There you can get a lot of answers on this kind of problems.

        One of the answers can be.
        Assuming you use the form2 as a kind of dialog than the most simple is
        \\\
        dim frm as new form2
        me.hide
        frm.showdialog
        me.show
        frm.dispose
        ///
        I hope this helps,

        Cor


        Comment

        • Munsifali Rashid

          #5
          Re: Unload a Form

          If the first form is your main form, unloading it will terminate your
          application. So, what you need to do, is just hide this form, and then
          unload it when you close the second form.

          Eg.

          'Create a new instance of the second form
          Dim MySecondForm As New Form2

          'Set the form owner
          MySecondForm.Ow ner = Me

          'Hide this form
          Me.Hide()

          'Show the second form
          MySecondForm.Sh ow()


          In the Form2_Closed event, you could have the following:

          'Unload the main form
          Me.Owner.Close( )


          This appears to work in a small test project I created, but I'm not sure if
          this is the correct practice. I hope someone else can confirm this is
          correct, or offer the correct way of doing this :-)

          Cheers,

          Mun


          --
          Munsifali Rashid




          "V.Boomessh " <anonymous@disc ussions.microso ft.com> wrote in message
          news:0a2201c3d6 a8$12ea4a60$a30 1280a@phx.gbl.. .[color=blue]
          > Hai,
          >
          > The code just ends the application and comes out. It is
          > not solving the problem.
          >
          > regards,
          > V.Boomessh
          >[/color]



          Comment

          Working...