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.

SelectedBackColor, SelectedForeColor

These properties determine the colors used to highlight text.

Usage

oObject.SelectedBackColor = nBackColor
nBackColor = oObject.SelectedBackColor
oObject.SelectedForeColor = nForeColor
nForeColor = oObjected.SelectedForeColor

Only a few controls (Edit box, Text box, Spinner, ComboBox) allow you to select text. These properties determine what colors are used for the selected text.

In a combo box, the selected colors affect only the text in the text box portion, not the drop-down list (where ItemBackColor, ItemForeColor, SelectedItemBackColor and SelectedItemForeColor hold sway). Plus, there’s a very interesting effect. The current item shows up with a background of SelectedBackColor, but there’s a small border around it in the combo’s BackColor. (When Style = 2—drop-down list, the text in the text box portion is always selected.) You can make some pretty sharp looking effects with this (or you can set it up to be not noticeable).

Example

* Change the defaults for all objects
* to black on red
ThisForm.SetAll("SelectedBackColor",RGB(255,0,0))
ThisForm.SetAll("SelectedForeColor",RGB(0,0,0))

See Also

BackColor, ForeColor, ItemBackColor, ItemForeColor, SelectedItemBackColor, SelectedItemForeColor, SelLength, SelStart, SelText