How to Place a Command Button in a Grid Cell Visually

Last reviewed: April 30, 1996
Article ID: Q127843
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

This article shows by example how to place a command button in a grid cell by using the Form Designer. These steps may also be used to place other Visual FoxPro controls in grid cells.

MORE INFORMATION

Step-by-Step Example

  1. Open a new form. From the File menu, choose New. Then select Form and click the New File push button.

  2. Place a new grid on the form by clicking the Grid Tool on the Form Controls Toolbar and then drawing the box for the Grid on the Form.

  3. On the Properties Sheet, under the All tab, change the ColumnCount property to 2. (This example will provide a 2 column grid.)

  4. Select Column1 from the Object DropDown in the Properties sheet.

  5. Change the Sparse property to .F. if you want the command button to appear on every row no matter where the cursor is. Leave the Sparse Property set to the default of .T. if you want the command button to appear only on the row the cursor is on.

  6. With Column1 still selected, click the command button tool on the Form Controls Toolbar. Then click any row in Column1. On the Properties sheet, you should see that the Object Command1 is selected.

  7. Change the Caption property of Command1 to "Push Me" (as an example).

  8. In the Click event of the command button, type this command:

    WAIT WINDOW "I'm here!"

  9. Select Column1 from the Object DropDown. Highlight the CurrentControl property under the All tab. Select Command1 from the DropDown, or double-click the property name.

  10. Add a table to the Data Environment. You may do this by choosing Data

        Environment from the View menu. Then click the right-mouse button and
        select Add Table. Now select a table from a currently open database, or
        select a Free Table. Once you have added a table, close the Data
        Environment window.
    

  11. Select Column2 from the Object DropDown in the Properties sheet.

  12. Set the ControlSource to one of the fields in the table you added to

        the Data Environment.
    

  13. Save the form, and run it.


Additional reference words: 3.00 VfoxWin
KBCategory: kbtool
KBSubcategory: FxtoolFormdes


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: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.