SelectedItemBackColor Property

Specifies the background color for a selected item in a ComboBox or ListBox or cell (TextBox only) in a Grid control. SelectedItemBackColor is related to the HighlightForeColor and HighlightBackColor properties in that you need to control the color of the selected cell in a Grid row. Read/write at design and run time.

Control.SelectedItemBackColor [= nColor ]

-or-

Control.SelectedItemBackColor = RGB( nRedValue, nGreenValue, nBlueValue )

Parameters

  • nColor
    Numeric data type. SelectedItemBackColor specifies an integer representing a single color value. Visual FoxPro derives the default color setting from the Windows operating system color setting for Selected Items. For information about valid color values, see BackColor, ForeColor Properties.

Remarks

You can find the Selected Items color setting in the Advanced Appearance dialog box, which you can open by going to the Start Menu, opening the Control Panel, selecting Display, clicking the Appearance tab, clicking Advanced, and selecting Selected Items from the Item drop-down list.

You can also define colors by entering the RGB value for the property in the Properties window or choose colors by double-clicking the property in the Properties window to display the Color dialog box. The red, green, and blue color values corresponding to the color you choose become the settings for these properties after you close the Color dialog box.

At the Grid control level, SelectedItemBackColor and SelectedItemForeColor apply only to TextBox controls. Though a Grid column can contain many different types of objects, only the default TextBox control is supported. You must set SelectedItemBackColor and SelectedItemForeColor individually at the control level for other controls. The priority of the GridSelectedItemBack and SelectedItemForeColor settings over the behavior of a specific TextBox control in the column is determined as follows:

  • When GridHighlightStyle is set to 0, GridSelectedItemBackColor and SelectedItemForeColor are disregarded, and the properties of the text box take precedence. If GridHighlightStyle is set to a value of 2, only the highlight colors persist, and selected items display only when a grid has focus.
  • When GridHighlightStyle is set to a value greater than 0, the following behavior applies:
    • The TextBox control properties control the actual colors of the selected text box.

    • When GridSelectedItemBackColor and SelectedItemForeColor are explicitly set, the corresponding properties for all TextBox controls the grid are set. This occurs at design time and run time.

    • The grid's property settings take precedence over conflicting text box property settings. If you want the TextBoxSelectedItemBackColor and SelectedItemForeColor to override the corresponding grid properties, set the individual text box properties after setting the grid properties.

      Tip   You can create routine that performs this process, which provides flexibility should the grid properties change at run time.

    • When setting the TextBoxBackColor and ForeColor properties to control how the text box displays when clicked for editing, the GridSelectedItemBackColor and SelectedItemForeColor properties behave as if the entire cell was selected.

You can reset the colors of a grid and its text boxes to their class default settings by calling the ResetToDefault method for the Grid and TextBoxSelectedItemForeColor and SelectedItemBackColor properties.

Note   This differs from how Visual FoxPro handles other grid color settings. For example, when you call ResetToDefault on a grid's BackColor property, the underlying columns and text boxes are set to the grid's default BackColor property and not the default BackColor properties of the columns and text boxes.

See Also

Properties | HighlightStyle Property | SelectedItemForeColor Property | TextBox Control | ResetToDefault Method | Selected Property | ItemBackColor, ItemForeColor Properties | RGB( ) Function

Applies To: ComboBox Control | ListBox Control | Grid Control