Tabpage add/remove

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

    Tabpage add/remove

    I knew that "Hide" doesn't work with Tabpage if I want to hide it. I should
    use Remove/Add. But I have some other controls in the tabpage which I don't
    want to use code to dynamiclly create them. If I use remove to remove that
    tabpage and later use add to add it back in, I have to write code to create
    all the controls inside that tabpage, otherwise it will be a blank page.
    What can I do to avoid it? Thank you for your time and help.
  • Claudio Grazioli

    #2
    Re: Tabpage add/remove

    On Wed, 25 May 2005 15:31:02 -0700, Cynthia wrote:
    [color=blue]
    > I knew that "Hide" doesn't work with Tabpage if I want to hide it. I should
    > use Remove/Add. But I have some other controls in the tabpage which I don't
    > want to use code to dynamiclly create them. If I use remove to remove that
    > tabpage and later use add to add it back in, I have to write code to create
    > all the controls inside that tabpage, otherwise it will be a blank page.
    > What can I do to avoid it? Thank you for your time and help.[/color]

    Instead completly removing the TabPages use some kind of a TabPageManager.
    This TabPageManager is a class having a collection of all your TabPages.
    When you have to show a TabPage you get it from the TabPageManager and add
    it to the TabControl. So if you remove a TabPage from the TabControl it
    still exists in the TabPageManager. So the next time you have to show the
    removed TabPage you get it again from the TabPageManager and add it to the
    TabControl.

    hth
    --
    Claudio Grazioli
    Our website about our photography and travel. Enjoy our picture galleries from around the world or read our blog about travel and photography


    Comment

    • Mick Doherty

      #3
      Re: Tabpage add/remove

      That should not happen unless you are trying to add a tabpage that is
      already on the tabcontrol or are trying to add a copy of it.

      See the methods on my site:
      http://dotnetrix.co.uk/tabcontrols.html --> Hide and Show Tabpages in a
      Tabcontrol.

      --
      Mick Doherty
      Dotnetrix offers Nothing. Standard and Premium versions available.



      "Cynthia" <Cynthia@discus sions.microsoft .com> wrote in message
      news:5E398C2D-0837-4BF5-9FD2-05DD00A24762@mi crosoft.com...[color=blue]
      >I knew that "Hide" doesn't work with Tabpage if I want to hide it. I
      >should
      > use Remove/Add. But I have some other controls in the tabpage which I
      > don't
      > want to use code to dynamiclly create them. If I use remove to remove
      > that
      > tabpage and later use add to add it back in, I have to write code to
      > create
      > all the controls inside that tabpage, otherwise it will be a blank page.
      > What can I do to avoid it? Thank you for your time and help.[/color]


      Comment

      • Ignacio Machin \( .NET/ C# MVP \)

        #4
        Re: Tabpage add/remove

        Hi,

        What if you keep a reference to the TabPage in an instance variable?
        You could add/Remove it at needed.

        Now a drawback of this is that you can only add it at the end of the
        collection, there is no a InsertAt() method :(

        Another posibility is to intercept the TabIndexChanged event and if revert
        the selected tabpage.



        cheers,

        --
        Ignacio Machin,
        ignacio.machin AT dot.state.fl.us
        Florida Department Of Transportation



        "Cynthia" <Cynthia@discus sions.microsoft .com> wrote in message
        news:5E398C2D-0837-4BF5-9FD2-05DD00A24762@mi crosoft.com...[color=blue]
        >I knew that "Hide" doesn't work with Tabpage if I want to hide it. I
        >should
        > use Remove/Add. But I have some other controls in the tabpage which I
        > don't
        > want to use code to dynamiclly create them. If I use remove to remove
        > that
        > tabpage and later use add to add it back in, I have to write code to
        > create
        > all the controls inside that tabpage, otherwise it will be a blank page.
        > What can I do to avoid it? Thank you for your time and help.[/color]


        Comment

        Working...