-
Apr 25th, 2012, 08:50 AM
#1
Thread Starter
New Member
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
-
Apr 25th, 2012, 09:05 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|