The information in this article applies to:
- Microsoft Visual FoxPro for Windows, versions 3.0, 5.0
SUMMARY
When focus has moved from the grid, it can be hard to determine which
record is selected in the grid. Highlighting the record will provide a
visual clue to the user. This is accomplished using the When and Valid
events as demonstrated in this article.
MORE INFORMATION
Step-by-Step Example
The following steps show how to highlight the selected record when the grid
has lost the focus. The code will produce a red highlight on the record
when you leave the grid.
- Create a new form, and add the Customer and Orders tables from
Samples\Data\Testdata.dbc to the Data Environment.
- Drag the Company field from the Customer table in the Data Environment
to the form. This creates a text box and sets its ControlSource property
to Company.
- Drag the Orders table from the Data Environment to the form to create a
grid and set its RecordSource property to Orders.
- In the grid's Valid Event, place the following line of code to turn the
highlight on:
This.SetAll("DynamicBackColor",STR(RGB(255,0,0)),"Column")
- In the grid's When event, place the following line of code to turn the
highlight off:
This.SetAll("DynamicBackColor",STR(RGB(255,255,255)),"Column")
- If you are using navigation buttons, add the following code to the
ReFresh Method of the grid:
This.SetAll("DynamicBackColor",STR(RGB(255,255,255)),"Column")
- Save and run the form.
As the user clicks from the grid to the text box, the red highlight will
appear. Clicking the grid removes the highlight. If you are using
navigation buttons, when you click one of them, the highlight is removed.
|