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. C#
  4. Creating identical tabs

Creating identical tabs

Scheduled Pinned Locked Moved C#
helptutorialquestion
4 Posts 2 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.
  • N Offline
    N Offline
    noahfields
    wrote on last edited by
    #1

    Hi, I'm working on a small app that has a tab panel and I need to create a new tab with a few buttons and text boxes each time a text file is opened. My problem is how to create an identical tab each time with all of the same buttons and boxes with all the same code. Any ideas? Thanks. -NF

    H 1 Reply Last reply
    0
    • N noahfields

      Hi, I'm working on a small app that has a tab panel and I need to create a new tab with a few buttons and text boxes each time a text file is opened. My problem is how to create an identical tab each time with all of the same buttons and boxes with all the same code. Any ideas? Thanks. -NF

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The best way is to extend TabPage with your own class and add all your controls and default logic to that class. Whenever you need to add a new tab to your TabControl, simply instantiate a new instance of your custom TabPage class and add that to TabControl.TabPages.

      Microsoft MVP, Visual C# My Articles

      N 2 Replies Last reply
      0
      • H Heath Stewart

        The best way is to extend TabPage with your own class and add all your controls and default logic to that class. Whenever you need to add a new tab to your TabControl, simply instantiate a new instance of your custom TabPage class and add that to TabControl.TabPages.

        Microsoft MVP, Visual C# My Articles

        N Offline
        N Offline
        noahfields
        wrote on last edited by
        #3

        Ok thanks for the help, I did what you instructed but the new TabPage will not show up on the form. I looked around for methods that seemed to help update Windows Forms controls. I found SuspendLayout() and ResumeLayout() and also Refresh(). I invoke SuspendLayout on the From, TabControl, and the TabPage before adding the controls to the TabPage, then to the TabControl. Then I do ResumeLayout(false) for all three objects after everything is done. That didn't work so I called Refresh() on everything that I logically could. Still no new tab? I made sure I added the TabPage to the TabControl and everything. Any ideas? Thanks again for your help. -NF

        1 Reply Last reply
        0
        • H Heath Stewart

          The best way is to extend TabPage with your own class and add all your controls and default logic to that class. Whenever you need to add a new tab to your TabControl, simply instantiate a new instance of your custom TabPage class and add that to TabControl.TabPages.

          Microsoft MVP, Visual C# My Articles

          N Offline
          N Offline
          noahfields
          wrote on last edited by
          #4

          Never mind I just had to much code mixed up all over the place, anyway, it works now. Thanks again for your help. -Noah Fields

          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