The TabControl element allows you to create a control with multiple tabs. And each tab will store some set of other controls, like buttons, text boxes, etc. Each tab is represented by a class TabPage.
To configure the tabs of the TabControl element, use the TabPages property. When you move the TabControl element from the toolbar to the form, two tabs are created by default – tabPage1 and tabPage2. Let’s change their display using the TabPages property:
This will open a window for editing/adding and deleting tabs:
Each tab represents a kind of panel to which we can add other controls, as well as a header that we can use to switch between tabs. The header text is set using the Text property.
To add a new tab, we need to create it and add it to the collection tabControl1.TabPages using the Add method:
//adding a tab
TabPage newTabPage = new TabPage();
newTabPage.Text = "Continents";
Deleting is as simple as this:
// tab removal
// by index
// by object
By getting the desired tab by index in the tabControl1.TabPages collection, we can easily manipulate it:
// change of the properties
tabControl1.TabPages.Text = "First Tab";
The SplitContainer element allows you to create two split panels. By changing the position of the splitter, you can change the size of these panels.
The SplitContainer element
Using the Orientation property, you can set the splitter to display horizontally or vertically on a form. In this case, this property takes values Horisontal and Vertical respectively.
In case you want to prohibit changing the splitter’s position, you can set the IsSplitterFixed property to true. That way the splitter will be fixed and we won’t be able to change its position.
By default, when a form is stretched or shrunk, both splitcontainer panels will also change size. However, we can fix one panel to a fixed width (when the splitter is vertically oriented) or height (when the splitter is horizontally oriented). To do this, we need to set the FixedPanel property of the SplitContainer element. It takes as value the panel which should be fixed:
To change the position of the splitter in the code, we can control the SplitterDistance property, which sets the position of the splitter in pixels from the left or top edge of the SplitContainer element. And we can use the SplitterIncrement property to set the step by which the splitter moves when you move it with the arrow keys.
To hide one of the two panels, we can set the property Panel1Collapsed or Panel2Collapsed to true