OptionButton, OptionGroup
Option buttons come in bunches, where only one can be chosen at a time. Option buttons are good for sets of mutually exclusive options. (For example, groups of ages such as 0–12, 13–24, 25–49, 50–64, and 65 and above.)Since options come only in sets, we can't create them individually. An OptionGroup is a container that holds option buttons. It's the group that has a Value, not the individual buttons. (Though, for some strange reason, individual option buttons do have ControlSource and Value—don't ask us why. We think they forgot to remove them when they added OptionGroups.)Like check boxes, option buttons can be textual or graphical. With graphical option buttons, the currently selected button stays depressed. If the group's Value doesn't correspond to any of the buttons (which shouldn't really occur, but FoxPro lets you do this), none of the buttons is down.OptionGroup
Property |
Value |
Purpose |
Logical |
Determines whether the group grows and shrinks to match the sizes of the buttons within. |
|
Numeric |
The number of buttons in the group. |
|
Collection |
References to the individual buttons in the group. |
|
Collection |
References to the individual buttons in the group. |
|
Numeric |
The number of the currently chosen button in the group. |
|
Character |
The caption of the currently chosen button in the group. |
OptionButton
Property |
Value |
Purpose |
Numeric |
Determines which side of the caption the button appears on. |
|
Logical |
Determines whether this button resizes itself when the caption changes. |
|
Character |
The text for the button. |
|
Character |
The names of graphics files used for a graphical option button. Picture is used when the button is not chosen. DownPicture is used when the button is chosen. DisabledPicture is used when the button is disabled. If either DownPicture or DisabledPicture is not specified, Picture is used in that circumstance. |
|
Numeric |
Determines the physical appearance of the button: 3-D (0); Plain (1), meaning flat; or Hot Tracking (2), meaning flat until it gets focus or the mouse is over it. Hot Tracking is applied only to graphical option buttons (Style = 1); ordinary option buttons with SpecialEffect set to 2 are flat. |
|
Numeric |
Determines whether the button is textual or graphical. |
|
Numeric |
The "tab" order of the button within the group. |
MouseEnter and MouseLeave don't follow this paradigm. Even when a button's MouseEnter or MouseLeave is empty, the group-level events don't fire as the mouse passes into or out of the button. But, as noted above, the reverse events do. That is, the group's MouseLeave fires as you enter the button, and the group's MouseEnter fires as you leave the button. |
Example |
* Here's one possible approach to subclassing * (except we'd really do this in the Class Designer, not code). DEFINE CLASS MyOptionGroup AS OptionGroup ButtonCount = 0 AutoSize = .T. PROCEDURE Init * Set up the buttons here. You won't see the * changes at design-time, but they'll be * right at runtime. This.Setall("Alignment", 1) This.Setall("AutoSize", .T.) ENDPROC ENDDEFINE |
See Also |
Alignment, AutoSize, ButtonCount, Buttons, Caption, DisabledPicture, DownPicture, MouseEnter, MouseLeave, Objects, Picture, Set KeyComp, SetAll, SpecialEffect, Style, TabIndex, Value |