Controls Property (Toolbar Control)

       

Returns a reference to a collection of controls contained on an object.

Syntax

object.Controls(index)

object.Controls.Item(index)

The Controls property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.
index A value that identifies a member of a Controls collection.

Remarks

The Controls property is similar to the Controls collection on the Form object, and is accessed in a similar manner. For example, use the following code to get the Top property of the second control on a Toolbar control:

MsgBox Toolbar1.Controls(2).Top

With the Controls property, you can iterate through all the controls on a Tab object or a Toolbar control and change the properties of each control as in the following code:

Dim ctlX As Control
For Each ctlX In Toolbar1.Controls
   ctlX.Width = _
   Toolbar1.Width / Toolbar1.Controls.Count
Next

Note   The Controls collection refers to controls contained by the Toolbar control, such as a ComboBox control, and not the Button objects, which are part of the control itself.