Microsoft KB Archive/128075

= PRB: Grid Does Not Respond to the Click or Dblclick Events =

Article ID: 128075

Article Last Modified on 8/24/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q128075



SYMPTOMS
The methods associated with the Click or DblClick events of a grid are not executed when a user clicks any element of the Grid. It seems events are not triggered when the grid is filled with data.



CAUSE
This behavior is by design. A grid object is a container of columns. Columns in turn contain controls. Methods defined in a container are not inherited in the container hierarchy. For example, the code you include in the Click event of a form is not executed when you click a command button.

When a grid is filled with data and you click a cell in the grid, the control, a text box by default, receives the Click event. The grid receives the click event in areas that contain no data.



WORKAROUND
Use the Click event procedure of the control to trap for a mouse click in a filled record.

Another way to trap for a mouse click anywhere on the grid is to cover the grid with a shape, and place code in the Click event of the shape. Make sure the Backstyle property of the shape is set to 0 for transparent and that the shape is on top. If the shape is not on top of the grid, you can place it there by selecting "Bring to Front" on the layout toolbar when the shape is selected.



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Create a form. When the form is displayed, choose Data Environment from the View menu. When the Data Environment window is displayed, click the right mouse button and select Add. Add the CUSTOMER table from the SAMPLES\DATA directory. Drag the table from the Data Environment to the Form. A grid is created. In the property sheet, select the Grid1 object, and modify the value of the Columncount property from -1 to 2.</li>  Double-click the Click Event entry in the Property Sheet to open the code window. Type the following code and close the code window: WAIT WINDOW "This is the Grid" </li> In the Property sheet, select the Text1 Object.</li>  Open the code window for the Click event of Text1, and enter this code: WAIT WINDOW "This is the Text control" </li> Save the form, and run it.</li></ol>

When the form is displayed, click several areas of the grid. The parts with data in the first column will display "This is the Text control"; the areas of the grid with no data will display a WAIT WINDOW with "This is the Grid."

Additional query words: VFoxWin

Keywords: KB128075

-

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

© Microsoft Corporation. All rights reserved.