Microsoft KB Archive/139090

= How To Highlight a Row in a Grid that Has Lost the Focus =

Article ID: 139090

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q139090



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.



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.</li></ol>

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.

Keywords: kbhowto kbcode KB139090

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.