Page Object

Description

One page of a MultiPage and a single member of a Pages collection.

Remarks

Each Page object contains its own set of controls and does not necessarily rely on other pages in the collection for information. A Page inherits some properties from its container; the value of each inherited property is set by the container.

A Page has a unique name and index value within a Pages collection. You can reference a Page by either its name or its index value. The index of the first Page in a collection is 0; the index of the second Page is 1; and so on. When two Page objects have the same name, you must reference each Page by its index value. References to the name in code will access only the first Page that uses the name.

The default name for the first Page is Page1; the default name for the second Page is Page2.

Properties

Accelerator property, ActiveControl property, CanPaste property, CanRedo property, CanUndo property, Caption property, ControlTipText property, Cycle property, Enabled property, HelpContextID property, Index property, InsideHeight, InsideWidth properties, KeepScrollBarsVisible property, Name property, Picture property, PictureAlignment property, PictureSizeMode property, PictureTiling property, ScrollBars property, ScrollHeight, ScrollWidth properties, ScrollLeft, ScrollTop properties, TabIndex property, TabStop property, Tag property, TransitionEffect property, TransitionPeriod property, VerticalScrollbarSide property, Visible property, Zoom property.

Methods

Copy method, Cut method, Paste method, RedoAction method, Repaint method, Scroll method, SetDefaultTabOrder method, UndoAction method.

See Also

Controls collection, MultiPage control, Pages collection, Tab object.

Example

The following example uses the Add, Clear, and Remove methods to add and remove a control to a Page of a MultiPage at run time.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • A MultiPage named MultiPage1.
  • Three CommandButton controls named CommandButton1 through CommandButton3.
    Dim MyTextBox As Control
    
    Private Sub CommandButton1_Click()
    Set MyTextBox = MultiPage1.Pages(0).Controls.Add("Forms.TextBox.1", _
    "MyTextBox", Visible) End Sub Private Sub CommandButton2_Click() MultiPage1.Pages(0).Controls.Clear End Sub Private Sub CommandButton3_Click() If MultiPage1.Pages(0).Controls.Count > 0 Then MultiPage1.Pages(0).Controls.Remove "MyTextBox" End If End Sub Private Sub UserForm_Initialize() CommandButton1.Caption = "Add control" CommandButton2.Caption = "Clear controls" CommandButton3.Caption = "Remove control" End Sub
Example

The following example uses the Add, Cut, and Paste methods to cut and paste a control from a Page of a MultiPage. The control involved in the cut and paste operations is dynamically added to the form.

This example assumes the user will add, then cut, then paste the new control.

To use this example, copy this sample code to the Declarations portion of a form. Make sure that the form contains:

  • Three CommandButton controls named CommandButton1 through CommandButton3.
  • A MultiPage named MultiPage1.
    Dim MyTextBox As Control
    
    Private Sub CommandButton1_Click()
        Set MyTextBox = MultiPage1.Pages(MultiPage1.Value).Controls.Add( _
    "Forms.TextBox.1", "MyTextBox", Visible) CommandButton2.Enabled = True CommandButton1.Enabled = False End Sub Private Sub CommandButton2_Click() MultiPage1.Pages(MultiPage1.Value).Controls.Cut CommandButton3.Enabled = True CommandButton2.Enabled = False End Sub Private Sub CommandButton3_Click() Dim MyPage As Object Set MyPage = MultiPage1.Pages.Item(MultiPage1.Value) MyPage.Paste CommandButton3.Enabled = False End Sub Private Sub UserForm_Initialize() CommandButton1.Caption = "Add" CommandButton2.Caption = "Cut" CommandButton3.Caption = "Paste" CommandButton1.Enabled = True CommandButton2.Enabled = False CommandButton3.Enabled = False End Sub