How to Highlight a Single Grid Field

Last reviewed: October 29, 1995
Article ID: Q138655
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

This article describes how to highlight the single grid cell in which the mouse pointer is located. Various other Microsoft Knowledge Base articles already exist that describe how to produce other grid visual effects, such as highlighting an entire row or selecting the entire field (cell) upon entry by using the Format property. The technique described in this article allows the user to positively identify the cell in which the pointer is currently located.

MORE INFORMATION

Step-by-Step Example

  1. Create a form with a data environment, and drag the table onto the form to create a grid.

  2. In the Grid.Init event, place the following code:

    This.Column1.Text1.SelectedBackColor = RGB(0,255,0)

  3. In the Grid.AfterRowColChange event, place the following code:

    MyColumn="Column"+ALLTRIM(STR(nColIndex)) This.&MyColumn..Text1.SelectedBackColor = RGB(0,255,0) This.&MyColumn..Text1.BackColor= This.&MyColumn..Text1.SelectedBackColor

  4. Run the Form, and either click a cell or press the TAB key to move into a cell. The cell will exhibit the color of the SelectedBackColor of the text box that usually is shown only on initial entry into the cell. The highlight color generally disappears when you start to type in the cell.

For more information about highlighting an entire row, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q130458
   TITLE     : How to Highlight the Entire Row in Grid When User Clicks


Additional reference words: 3.00 VFoxWin
KBCategory: kbprg kbhowto
KBSubcategory: FxprgGrid


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 29, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.