Tab Controls and Tab Pages |
|
Description of Tab Controls |
As your application becomes crowded with various controls, you may find its form running out of space. To solve such a problem, you can create many controls on a form or container and display some of them only in response to some action from the user. The alternative is to group controls in various containers and specify when the controls hosted by a particular container must be displayed. This is the idea behind the concept of property pages. A property page is a control container that appears as a form or a frame. |
A property page can appear by itself. Here is an example labeled Signatures: In most other cases, a property page appears in a group with other pages. It functions like a group of pieces of paper placed on top of each other. Each piece is represented by a tab that allows the user to identify it: To use a property page, the user clicks the header, also called tab, of the desired page. This brings that page up and sends the other(s) in the background: If the user needs access to another page, he or she can click the desired tab, which would bring that page in front and send the previously selected page to the back. The pages are grouped and hosted by an object called a property sheet. Like a form, the property pages of a property sheet are simply used to carry or hold other controls. The major idea of using a property sheet is its ability to have many controls available in a relatively smaller area.
The property pages of a property sheet are also referred to as tab controls. To support property pages, the .NET Framework provides a class named TabControl. At design time, to add a property sheet to your application, in the Containers section of the Toolbox, click TabControl and click the form (or another container). To programmatically create a property sheet, declare a variable of type TabControl, allocate memory for it using the new operator. Like all other objects, a tab control must have a name. After declaring the variable and initializing it, add it to the Controls collection of its container. Here is an example of creating a tab control: Imports System Imports System.Drawing Imports System.Windows.Forms Module Exercise Public Class WinControls Inherits Form Private tclPropertySheet As TabControl Dim components As System.ComponentModel.Container Public Sub New() InitializeComponent() End Sub Public Sub InitializeComponent() Size = New Size(345, 228) StartPosition = FormStartPosition.CenterScreen tclPropertySheet = New TabControl() tclPropertySheet.Location = New Point(14, 16) tclPropertySheet.Size = New Size(310, 170) Controls.Add(tclPropertySheet) End Sub Public Shared Function Main() As Integer Application.Run(New WinControls()) Return 0 End Function End Class End Module This would produce:
If you want the property sheet to occupy the whole form or to occupy a section of it, you can specify this using the Dock property. |
|
||
Home | Copyright © 2007-2013, FunctionX | Next |
|