Page 283 - Excel Progamming Weekend Crash Course
P. 283

n540629 ch20.qxd  9/2/03  9:35 AM  Page 258




                258                                                         Saturday Evening

               The Frame Control

               The Frame control is used to group other controls; it has no functionality of its own,
               although it can detect Click events. A Frame control displays as a rectangular bordered box
               with a caption. After placing a Frame control on a form, you can place other controls on it.
               This provides the following capabilities:

                   If you move the Frame control (either while designing the form or in code), the con-
                   tained controls move along with it.
                   If you set the Visible property of the Frame control to False, all of its contained
                   controls are hidden as well.
                  The most common use for a Frame control is to create groups of OptionButton controls.
               An example of this is presented in the section on the OptionButton control later in this
               session.


               The Label Control
               The Label control displays text that the user cannot edit. It is used to provide information
               or instructions on a form. For example, you can place a Label control next to a TextBox con-
               trol to identify the TextBox and specify what data it contains. While the user cannot edit a
               Label control, its text can be changed in code (via the Caption property). Furthermore, it
               can detect Click events so it can be used as an alternative to the CommandButton control
               as a way of initiating actions in response to user input.


               The OptionButton Control
               The OptionButton is similar to a CheckBox control in that it permits the display and selec-
               tion of a True/False, yes/no option, usually as a small circle that is empty when the option
               is off and filled when the option is on; the user toggles it by clicking. The OptionButton is
               different in that one and only one of a group of OptionButton controls can be selected at a
               time.
                  A group of OptionButtons can be defined by placing them all within a Frame control. The
               technique is to first place the Frame control on the form and then place the OptionButton
               controls on the frame. You must place the OptionButton directly on the Frame control to
               make it part of the group — you cannot drag an existing OptionButton from another part
               of the form onto the frame.
                  Another way to define a group of OptionButtons is by means of the GroupName property.
               All OptionButton controls with the same GroupName are considered to be part of a group,
               and are mutually exclusive even if they are not together in a Frame control.
                  Setting an OptionButton’s Value property to True automatically sets other buttons in the
               same group to False. To determine which OptionButton in a group is selected, your code
               must go through all the OptionButton controls looking for one whose Value property is
               True. This is demonstrated in the demo program.
   278   279   280   281   282   283   284   285   286   287   288