The Appearance of the Properties Window |
|
|
To manipulate an object, you can use the Properties
window:
|
Practical Learning: Introducing
Properties
|
|
- Start Microsoft Excel
- On the Ribbon, click Developer
- In the Controls section, click Insert
- Under ActiveX Controls, click any object and click the main area of the
spreadsheet
- Right-click the object you added and click Properties
After adding a control to your application, you can manipulate its
characteristics. If you are working in Microsoft Excel, to put a control
into edit mode, in the Controls section of the Ribbon, click the Design
Mode button .
Each field in the Properties window has two sections: the property’s
name and the property's value:
The name of a property is represented in the left column. This is the
official name of the property. Notice that the names of properties are in
one word. Based on this, our House class would have been defined as
follows:
House
[
Address
TypeOfHouse
NumberOfBedrooms
NumberOfBathrooms
HasIndoorGarage
LivingRoomCoveredWithCarpet
KitchenHasIslandStove
]
You can use this same name to access the property in code.
Accessing a Control's Property |
|
To access a property of a control using code, type the
name of the control, followed by a period, followed by the name of the
property. Based on this, if you have a House object named Langston, to
access its TypeOfHouse property, you would write:
Langston.TypeOfHouse
The box on the right side of each property name represents the value of
the property that you can set for an object. There are various kinds of
fields you will use to set the properties. To know what particular kind a
field is, you can click its name. To set or change a property, you use
the box on the right side of the property’s name: the property's value,
also referred to as the field's value.
The Default Value of a Control's Property |
|
To programmatically change the value of a property, type the
name of the control, followed by a period, followed by the name of the
property, followed by =. Then, on the right side of equal, you must
provide the value but this depends on the type of value.
The people who developed the controls also assigned some primary values to
their properties. This is the type of value that a property either is most
likely to have or can use unless you decide to change
it. The primary value given to a property is referred to as its default
value. Most of the time, you can use that property. In some other
assignments, the default value will not be suitable.