If you were to write this code: Panel1.Enabled = Not Panel1.Enabled Add a couple of controls inside the panel. If the tabpage gets disabled or hidden from view, so will the panel with all its controls inside, as it inherits capabilities from its parent control. Now we sit with a Container control inside a Container control. It should add the Panel inside the tabpage if it doesn’t, just drag the panel onto the tabpage. Make sure the first TabPage is selected on the form, then double click on the panel in your Toolbox. An added benefit is that if you set its properties good enough, you will always maintain the same look and feel of your form irrespective of the form’s size.Īll of the Panel’s methods and properties can be found on this MSDN link. The Panel not only serves as a container control, its main purpose is to help organize your controls on your forms better.
Why? Well, because of its simplicity and ease of use. PanelĪ Panel is the perfect container control. It increases or decreases the counter i (which is a modular variable), and sets the tabcontainer’s SelectedIndex to the value of the counter variable.
Toolstrip vs menustrip code#
This code assumes you have two buttons named btnNext and btnPrev respectively.
TabContainer.SelectedIndex = i 'Jump to previous tab index Private Sub btnNext_Click(sender As System.Object, e As System.EventArgs) Handles btnNext.Click I also included code to navigate backwards in the same manner. If the last tabpage is reached, it will continue again from the start. The following code will automatically navigate to the next tab. You can click on each tab individually, or you can navigate through code. TabPage Navigationīefore I move onto the next topic, you have to know that navigation between tabpages is quite easy.
These tabs are all empty at this stage, as you have to add the content manually. Your Form will now display your TabControl along with its six new tabs. If all went well, your TabPage Collection Editor should resemble Figure 4.įigure 4 – TabPage Collection Editor with your tabs Try to create a TabControl with the following tabs: To rearrange the order of the tabs, click on the up or down arrows respectively. To edit each Tabpage’s properties, use the Properties window inside this screen. A screen similar to the following Figure will pop up. In your Properties window, click on the TabPages Property. This allows you to add, remove and edit the tabpages on the tabcontrol. The Property to note is the TabPages property. The TabControl has many Methods and properties, as shown here on this MSDN link. This means that instead of separating content into different forms, you could have one TabControl on one form, with all the desired information. It allows for the capability to have multiple little screens of content, all separated into tabs. You can find all of these controls bar one, in your Toolbox under the Containers section as shown in Figure 1.įigure 1 – Standard Container Controls TabControl Now that you know what a Container control’s purpose is, let’s start playing with them, one by one. Container controls can obviously host other Container controls as well then you’re looking at a grandparent, parent and child relationship. The host is known as the parent, and the controls inside the host are known as the children. The Form is the perfect example here, as you put all your controls on the form.
Toolstrip vs menustrip how to#
Today I will set this record straight with this article and explain exactly what Container controls are, which Container controls are available, and how to use them What are Container Controls?Ĭontainer controls, as their name implies, are controls that can host other controls inside them. It is as if newbies do not realize the true power of a container control. Container controls are a misunderstood concept for many a new programmer.