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
- Open a new form. From the File menu, choose New. Then select Form and
click the New File push button.
- 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.
- On the Properties Sheet, under the All tab, change the ColumnCount
property to 2. (This example will provide a 2 column grid.)
- Select Column1 from the Object DropDown in the Properties sheet.
- 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.
- 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.
- Change the Caption property of Command1 to "Push Me" (as an example).
- In the Click event of the command button, type this command:
WAIT WINDOW "I'm here!"
- 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.
- 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.
- Select Column2 from the Object DropDown in the Properties sheet.
- Set the ControlSource to one of the fields in the table you added to
the Data Environment.
- Save the form, and run it.
|