[Overview][Types][Classes][Procedures and functions][Index] | Reference for unit 'ExtCtrls' (#lcl)

# TUNBPages.AddObject

Adds the specified page object to the list of pages.

## Declaration

Source position: extctrls.pp line 110

`public function TUNBPages.AddObject(`
`const S: string;`
`AObject: TObject`
`):Integer; override;`

## Arguments

`S` |  | Identifier used as the name and caption for the page object.
`AObject` |  | Object with the TPage instance stored in the method.

## Function result

Ordinal position in the page list where the specified page object was stored.

## Description

AddObject is an overridden method in TUNBPages used to add the specified object to the page list maintained in the class instance. It re-implements the virtual method introduced in TStrings, and does not call the inherited method.

S contains the string used to identify the page instance in AObject. The value is used as the Caption for the page object, and as the basis for the Name used in the TPage class instance. The Name for the class instance must be a unique identifier (when specified) in the Components for the TNoteBook control owner. A numeric suffix is appended to the Name value if S is not a unique identifier name on the owner of the TNotebook control. If S is not specified (contains ''), the Name for the class instance is not assigned.

AObject is the page instance added to the internal list. AddObject ensures that AObject is cast to TPage and its properties are initialized:

- Sets Name to the unique identifier derived from S when S is not an empty string.
- Sets Caption to the value specified in S (which can be an empty string).
- Sets Parent to the TNotebook instance which owns the page list.
- Sets Align to alClient to align the page to the client area for the TNotebook control.
- Sets Visible to False.
- Sets control style flags so that the page is not visible at design-time.

The return value is the ordinal position in the internal page list where AObject was stored. If the notebook does not already have an active page, the return value is assigned as the active PageIndex in the notebook control.

AddObject is called from the Add method using the TPage instance created in that method.

## See also

TUNBPages.Add |  | Creates a new page instance with the specified name.
TPage.PageIndex |  | Ordinal position for the page in its Notebook.
TPage.Visible |  | Allows the control, and all of its children, to be displayed or hidden.
TNotebook.PageIndex |  | Ordinal position for the active page in the notebook control.
TNotebook.Pages |  | Contains the page names and TPage instances defined for the notebook control.
TControl.Caption |  | The text displayed for the control.
TControl.Parent |  | The control within which the control is shown.
TControl.Align |  | Specifies the placement of the control on its Parent control.
TComponent.Name