Partilhar via


AllowCellSelection Property

Specifies whether one can select individual cells in a grid, for example, you can use the AllowCellSelection property to mimic a list box. Available at design time and run time.

Grid.AllowCellSelection [= lExpr]

Return Value

  • lExpr
    Specifies whether you can select the contents of a grid cell or only the entire row.

    The following table lists the values for lExpr.

    lExpr Description

    True (.T.)

    Specifies that one can select contents in a grid cell (field). (Default)

    False (.F.)

    Specifies that one must select the entire the row.

Remarks

Applies To: Grid Control

Selecting individual cells or the entire row does not change color of the selected row or cell.

When AllowCellSelection is set to False (.F.), the following additional behavior occurs:

  • The grid disregards the SelectedItemForeColor and SelectedItemBackColor properties. The row takes on a uniform color based on the HighlightBackColor and HighlightForeColor properties and other color-related properties at the column level.

    Note

    If you do not specify colors for the highlighting properties, a rectangular outline appears around a selected row.

  • If the HighlightStyle property is set to a value greater than 0, the default HighlightBackColor is a 50 percent lighter gradient.

  • The grid always shows the cursor specified with the MousePointer property and does not display a text insertion pointer when inside a cell. Clicking a cell selects the entire row, instead of setting focus to the individual cell.

  • Tabbing between cells is disabled, and grid behavior acts similar to a grid with a single column.

  • You cannot select a row in the grid for deletion by clicking the deletion column as this functionality is disabled.

  • Hidden columns are disregarded. You can view columns that are scrolled to the left or right outside the visible grid by using the LEFT ARROW and RIGHT ARROW keys or the mouse and the horizontal scrollbar.

  • The ActiveColumn property evaluates to 0; use the RelativeColumn property to obtain the correct column in the grid.

  • The ActivateCell method merely selects the entire row.

  • All events are handled at the grid level instead of at the control level. For example, double-clicking a cell is handled by the Grid.DblClick event. However, header events and attributes are still supported. For example, you can click on a header to resort the column's contents based on the field.

  • Support for Find is disabled as well as Edit menu commands because setting AllowCellSelection makes the grid read-only. However, the AllowCellSelection property does not affect the delete mark column in a grid.

  • The AfterRowColChange and BeforeRowColChange events only work for row change. The RowColChange property always returns a value of 1 (Row Change).

The AllowCellSelection property supports all standard Visual FoxPro controls; however, ActiveX controls embedded within a column are not supported.

If the AllowCellSelection property for a grid is set to True (.T.), Visual FoxPro disregards the Grid.KeyPress event and uses the event at the individual cell level.

See Also

Reference

ActiveColumn Property
AfterRowColChange Event
BeforeRowColChange Event
HighlightBackColor Property
HighlightStyle Property
RelativeColumn Property
SelectedItemForeColor Property
KeyPress Event

Other Resources

Properties (Visual FoxPro)