Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Style

This property is a prime example of polymorphism at work. Six different controls have it, and it has five different interpretations.

Usage

oObject.Style = nStyle
nStyle = oObject.Style

For combos, Style determines whether you get a drop-down list or a real combo (called a “drop-down combo”) that lets you type in new data. With a drop-down combo, new items aren’t automatically added to the combo’s list. You’ll have to handle them in code—see DisplayValue for details. Combos are the only control where the choices are 0 and 2. We do wonder what they have in mind for Style = 1.

For check boxes and option buttons, Style distinguishes graphical objects from textual ones. Unless Style is 1–graphical, any pictures you specify are ignored, as is the Hot Tracking setting for SpecialEffect.

Style for command buttons lets you make some of them “invisible”—one way to create a “hot spot” on a form. Although invisible buttons have no physical presence on a form, they can still gain focus, complete with a focus rectangle. Consider setting TabStop to .F. for invisible buttons to make them mouse-only.

Beginning in VFP 7, separators have the Style property. In this case, it determines whether they are 0–invisible (the default) or 1–display as a ruled line. Now that we have this option, we doubt we’ll ever be using invisible separators again. To our annoyance, the new setting is only effective at runtime. At design-time, separators are just as elusive as they’ve ever been.

Finally, there’s one backward-compatibility choice here. Set a text box’s Style to 1 if you want it to behave more or less like an @ … SAY in FoxPro 2.x. We haven’t found a way to refresh these text boxes (when the value is an expression) other than reassigning the original value. Guess they really are like @ … SAYs.

Example

* Normally, you'll set this property at design-time. But let's
* change a combo to a drop-down list.
ThisForm.cboMyCombo.Style = 2

See Also

@…Say, CheckBox, ComboBox, CommandButton, DisabledPicture, DisplayValue, DownPicture, OptionButton, Picture, Separator, SpecialEffect, TextBox, Valid