Remove not hide User Control, posting again

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike TI

    #1

    Remove not hide User Control, posting again

    March 24, 2006

    Hi all

    I am new to VB.NET and am using VB.NET 2005.

    I have an MDI form with a Split Container Control. On demand I am adding and
    removing User Controls on Panel 2. I am using Show() and Hide(). It works
    perfectly. The only thing is I would like to remove the User Control from
    memory instead of hiding. I tried Dispose(), however then I cannot show this
    user control again.

    UserControl.Par ent=Form.SplitC ontainer1.Panel 2
    UserControl.Doc k=DockStyle.Fil l
    UserControl.Sho w()
    ..
    ..
    UserControl.Hid e()

    Thanks.


  • Armin Zingler

    #2
    Re: Remove not hide User Control, posting again

    "Mike TI" <sunsetaaa@hotm ail.com> schrieb[color=blue]
    > March 24, 2006
    >
    > Hi all
    >
    > I am new to VB.NET and am using VB.NET 2005.
    >
    > I have an MDI form with a Split Container Control. On demand I am
    > adding and removing User Controls on Panel 2. I am using Show() and
    > Hide(). It works perfectly. The only thing is I would like to remove
    > the User Control from memory instead of hiding. I tried Dispose(),
    > however then I cannot show this user control again.[/color]

    This is a contradiction: Remove from memory .... show again.

    If you removed something from memory, you can not show it again because it
    does not exist anymore.
    [color=blue]
    > UserControl.Par ent=Form.SplitC ontainer1.Panel 2
    > UserControl.Doc k=DockStyle.Fil l
    > UserControl.Sho w()
    > .
    > .
    > UserControl.Hid e()
    >
    > Thanks.[/color]


    Armin

    Comment

    • Mike TI

      #3
      Re: Remove not hide User Control, posting again

      I mean is it possible for me to show the user control again and again on
      demand with the same behaviour as it was displayed for first time (firing
      load event etc.) instead of using Hide() which probably is the same thing as
      Visible=False.

      Thank you.

      "Armin Zingler" <az.nospam@free net.de> wrote in message
      news:ePo5jiyTGH A.4492@TK2MSFTN GP09.phx.gbl...[color=blue]
      > "Mike TI" <sunsetaaa@hotm ail.com> schrieb[color=green]
      >> March 24, 2006
      >>
      >> Hi all
      >>
      >> I am new to VB.NET and am using VB.NET 2005.
      >>
      >> I have an MDI form with a Split Container Control. On demand I am
      >> adding and removing User Controls on Panel 2. I am using Show() and
      >> Hide(). It works perfectly. The only thing is I would like to remove
      >> the User Control from memory instead of hiding. I tried Dispose(),
      >> however then I cannot show this user control again.[/color]
      >
      > This is a contradiction: Remove from memory .... show again.
      >
      > If you removed something from memory, you can not show it again because it
      > does not exist anymore.
      >[color=green]
      >> UserControl.Par ent=Form.SplitC ontainer1.Panel 2
      >> UserControl.Doc k=DockStyle.Fil l
      >> UserControl.Sho w()
      >> .
      >> .
      >> UserControl.Hid e()
      >>
      >> Thanks.[/color]
      >
      >
      > Armin[/color]


      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Remove not hide User Control, posting again

        Mike,

        Of course you only have to instance it from its class and add it to your
        form again.

        Dim myControl as New myUsercontrol.
        me.controls.add (myControl)

        And set than the right properties again.

        I hope this helps,

        Cor

        "Mike TI" <sunsetaaa@hotm ail.com> schreef in bericht
        news:%23xIiUryT GHA.1868@TK2MSF TNGP09.phx.gbl. ..[color=blue]
        >I mean is it possible for me to show the user control again and again on
        >demand with the same behaviour as it was displayed for first time (firing
        >load event etc.) instead of using Hide() which probably is the same thing
        >as Visible=False.
        >
        > Thank you.
        >
        > "Armin Zingler" <az.nospam@free net.de> wrote in message
        > news:ePo5jiyTGH A.4492@TK2MSFTN GP09.phx.gbl...[color=green]
        >> "Mike TI" <sunsetaaa@hotm ail.com> schrieb[color=darkred]
        >>> March 24, 2006
        >>>
        >>> Hi all
        >>>
        >>> I am new to VB.NET and am using VB.NET 2005.
        >>>
        >>> I have an MDI form with a Split Container Control. On demand I am
        >>> adding and removing User Controls on Panel 2. I am using Show() and
        >>> Hide(). It works perfectly. The only thing is I would like to remove
        >>> the User Control from memory instead of hiding. I tried Dispose(),
        >>> however then I cannot show this user control again.[/color]
        >>
        >> This is a contradiction: Remove from memory .... show again.
        >>
        >> If you removed something from memory, you can not show it again because
        >> it does not exist anymore.
        >>[color=darkred]
        >>> UserControl.Par ent=Form.SplitC ontainer1.Panel 2
        >>> UserControl.Doc k=DockStyle.Fil l
        >>> UserControl.Sho w()
        >>> .
        >>> .
        >>> UserControl.Hid e()
        >>>
        >>> Thanks.[/color]
        >>
        >>
        >> Armin[/color]
        >
        >[/color]


        Comment

        • Stephany Young

          #5
          Re: Remove not hide User Control, posting again

          Of course you can. That's the whole rationale behind instantiating objects.

          Just create an new instance of the component, set all the relevant
          properties as required and hook up the event handlers as required and Bob's
          your uncle.


          "Mike TI" <sunsetaaa@hotm ail.com> wrote in message
          news:%23xIiUryT GHA.1868@TK2MSF TNGP09.phx.gbl. ..[color=blue]
          >I mean is it possible for me to show the user control again and again on
          >demand with the same behaviour as it was displayed for first time (firing
          >load event etc.) instead of using Hide() which probably is the same thing
          >as Visible=False.
          >
          > Thank you.
          >
          > "Armin Zingler" <az.nospam@free net.de> wrote in message
          > news:ePo5jiyTGH A.4492@TK2MSFTN GP09.phx.gbl...[color=green]
          >> "Mike TI" <sunsetaaa@hotm ail.com> schrieb[color=darkred]
          >>> March 24, 2006
          >>>
          >>> Hi all
          >>>
          >>> I am new to VB.NET and am using VB.NET 2005.
          >>>
          >>> I have an MDI form with a Split Container Control. On demand I am
          >>> adding and removing User Controls on Panel 2. I am using Show() and
          >>> Hide(). It works perfectly. The only thing is I would like to remove
          >>> the User Control from memory instead of hiding. I tried Dispose(),
          >>> however then I cannot show this user control again.[/color]
          >>
          >> This is a contradiction: Remove from memory .... show again.
          >>
          >> If you removed something from memory, you can not show it again because
          >> it does not exist anymore.
          >>[color=darkred]
          >>> UserControl.Par ent=Form.SplitC ontainer1.Panel 2
          >>> UserControl.Doc k=DockStyle.Fil l
          >>> UserControl.Sho w()
          >>> .
          >>> .
          >>> UserControl.Hid e()
          >>>
          >>> Thanks.[/color]
          >>
          >>
          >> Armin[/color]
          >
          >[/color]


          Comment

          • Armin Zingler

            #6
            Re: Remove not hide User Control, posting again

            "Mike TI" <sunsetaaa@hotm ail.com> schrieb[color=blue]
            > I mean is it possible for me to show the user control again and
            > again on demand with the same behaviour as it was displayed for
            > first time (firing load event etc.) instead of using Hide() which
            > probably is the same thing as Visible=False.[/color]



            If you do not want to use Hide, you have to remove it from the container
            control, call Dispose and remove remaining references. Whenever you need a
            control again, you can create it, set it's properites and add it to the
            container (TheContainer.C ontrols.Add). If you have a variable declared using
            "WithEvents " that was previously pointing to the former control, you can
            assign the new control to this variable again and all event procedures will
            be working just like with the former control. If you don't have a WithEvents
            variable, use the AddHandler statement to attach event handlers to the new
            control.


            Armin

            Comment

            Working...