Results 1 to 2 of 2

Thread: Question about tabs

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2012
    Posts
    1

    Thumbs up Question about tabs

    I am using VB 2010.

    I have two things:
    - A Panel p1, that I have added a bunch of objects to: textboxs, buttons, etc
    - A TabControl tc1

    How would I with code add the panel (p1) to any new tabpage that has been created.

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,301

    Re: Question about tabs

    You wouldn't use a Panel. A Panel is just one control so it can only be on one TabPage at a time. If you want a specific set of controls to appear on every TabPage then you should create a UserControl. You add a UserControl to your project in basically the same way as you add a Form. You also design the UserControl in the same way as you do a Form, adding child controls from the Toollbox and then adding event handlers and other code. Once you build your project, the UserControl will appear in the Toolbox and you can then treat it like any other control, e.g. add it to a TabPage. Just like other controls, you can also create instances in code and add them at run time.

    If you intend to add this UserControl to every TabPage that you create then the best option is to create your own custom TabPage class and have it create its own UserControl. For an example of this, follow the CodeBank link in my signature and check out my thread on a Tabbed Web Browser. It includes a WebBrowserTabPage class that, when created, creates and adds its own WebBrowser control. You can do the same thing with your UserControl.

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