Property Sheets and Property Pages |
|
Property Sheets and Property Pages |
Description |
As your application becomes crowded with various controls, you may find yourself 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, as one. Here is an example:
|
If the user needs access to another page, he can click the desired tab, which would bring that page in front and send the previously selected to the back. The pages are grouped and hosted by an object called a property sheet. Like a form, the 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 smaller container.
Property pages of a property sheet are also referred to as tab controls. In the VCL, a property sheet is based on a class named TPageControl. The TPageControl class implements the TCustomTabControl class that is derived from TWinControl:
To visually create a property sheet, from the Win32 section of the Tool Palette, click TPageControl and click the form that would be used as the property sheet platform. To create, add, or remove the actual property pages of the property sheet, you can right-click the PageControl control:
Many of the effects you will need on pages have to be set on the page control and not on individual pages. This means that, to manage the characteristics of pages, you will change the properties of the parent page control control. At any time, whether working on the page control control or on one of its property pages, you should first know what object you are working on by selecting it. To select the page control control itself, you have two main options:
We saw that, to add property pages to a page control object, you can right-click it and click New Page. Of course, you can also add pages programmatically. To make use of a property page, for example to add controls to it, you must first select the desired property page.
Each page of a property is an object based on the TTabSheet class. This class is derived from TWinControl. At any time, one property page is selected when its tab is in front. If there are other property pages, their tabs would be in the back. The page whose tab is in front or selected is also referred to as the Active Page. To select a property page, you have three main options:
Like all other controls, the names of property pages are cumulative. As you add them, the first would be named TabSheet1, the second would be TabSheet2, etc. If you plan to programmatically refer to the property pages, you should give them more explicit names. As done with any other control, to set the name of a property page, after selecting it, on the Object Inspector, change the value of the Name property.
|
If you want the property sheet to occupy the whole form or to occupy a section of it, you can specify this using the Align property. A PageControl by itself can be used as a control and you can place the necessary controls on it, but this is usually not the reason you would need a PageControl control. IIf you want the property pages to have bitmaps on their tabs, you should first add a series of images using an ImageList control and then assign that control to the Images property of the PageControl object. After adding the PageControl control to your form and after adding one or more property pages, the property pages are created where the PageControl control is positioned and its dimensions are used by the eventual property pages. This means that, if you want a smaller or larger property sheet, you must modify the dimensions of the PageControl control and not those of the property pages, even though each property page has a location (Left and Top properties) and dimensions Height and Width properties).
If you have added pages but do not like their sequence, especially after adding the desired controls, you can move the page and change their sequence. The property pages are stored in a zero-based array. Each page has an index represented by the PageIndex property. The first page has a PageIndex value of 0, the second, if available, has a value of 1, etc. To move the property page, after selecting it, on the Object Inspector, change its PageIndex value. The value must be an unsigned integer less than the total number of pages.
Probably the first obvious characteristic of a property page is the word or string that identifies it to the user. That is, the string that displays on the tab of a property page. This is known as its title or caption. By default, the captions are set cumulatively as the pages are added. Usually you will not use these titles because they are meaningless. To display a custom title for a property page, first select it and, on the Object Inspector, change the value of the Caption property. You can also change the title of a property page programmatically, for example, in response to an intermediary action. To change the title of a page, assign a string to its Caption property. Here is an example: //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { pgeSecurity->Caption = "Security Issues"; } //--------------------------------------------------------------------------- If you had associated an ImageList control with the PageControl object and you want to use images on the title of a property page, specify the desired image using the ImageIndex property. You can use the images on some or all property pages. If you do not want an image on a certain property page, set its ImageIndex value to -1.
If for some reason you do not want to show a property page but do not want to delete it, you can hide it by setting its TabVisible property to false.
If you have many property pages and the width of the PageControl cannot show all tabs at the same time, the control would add two navigation arrow buttons to its top right corner to let the user know that there are more property pages:
By default, the navigation buttons would come up because the control uses a property that controls their availability. If you do not want the navigation arrows, you can set the MultiLine property of the PageControl control to true:
This would create cascading tabs and the user can simply select the desired property page from its tab:
As you are adding pages to a PageControl control, the tabs of the pages are positioned on the top border of the PageControl area. You can reposition them to the left, the right, or the bottom borders of the control. The placement of the tab is set using the TabPosition property of the PageControl. The possible values of this property are tpTop, tpLeft, tpRight, and tpBottom:
If you want to create a discrete property sheet and do not want to display the traditional tabs, you can replace the tabs with buttons. This option works only if the TabPosition property is set to tbTop, that is, only if the tabs would have been positioned to the top border of the control.
To display buttons instead of tabs, use the Style property. Its values are tsTabs, tsButtons, and tsFlatButtons. The button options produce the following effects:
If you attempt to set the Style property to a button's value when the tabs are not positioned on top, you would receive an error message.
To assist you with creating a property sheet, Embarcadero C++Builder provides a template. To get it, display the New Items dialog box. In the left list, click C++Builder Files. In the right list, click Tabbed pages:
Click OK. This would create a dialog box showing a property sheet that is equipped with three property pages and three buttons:
You can then customize any of its aspects as you see fit. For example, you can one one or more property pages. You can delete one or more property pages, you can change the names and captions of the property pages. And you can add controls either to the property pages or to the bottom section of the dialog box. |
|
|||||||||||||||||||||||||||||||||||
|
|
||
Home | Copyright © 2010-2016, FunctionX | |
|