Mike Lewis
Programmer
I've just made a happy discovery which I thought I'd share.
I've often had difficulty trapping double-clicks in a grid. If the user double-clicks in a cell, it is the DblClick of the textbox within the column that fires. If they double-click in a blank part of the grid, the DblClick of the grid itself fires. (The same is true of single clicks and right clicks, of course.)
Apart from the trouble of having to trap multiple DblClick events, this raises a problem. If you don't bind the grid to a recordsource until runtime, the column objects don't exist at design time, so there is no way to write code in their event-handlers.
It turns out that if you set the grid's AllowCellSelection to .F. (this property is new in VFP 8.0), then the individual textbox never gets focus, so it is always the grid's DblClick that fires. That makes it much easier to write code to trap the event, since you only have to write the code in one place, and the grid's DblClick is always available at design time.
What's more, the act of double-clicking also selects a record, so you can still use the record number to find out which row the user double-clicked on. (Unfortunately, that doesn't apply if they click in an empty portion of the grid.)
Mike
Mike Lewis
Edinburgh, Scotland
My Visual Foxpro web site: My Crystal Reports web site:
I've often had difficulty trapping double-clicks in a grid. If the user double-clicks in a cell, it is the DblClick of the textbox within the column that fires. If they double-click in a blank part of the grid, the DblClick of the grid itself fires. (The same is true of single clicks and right clicks, of course.)
Apart from the trouble of having to trap multiple DblClick events, this raises a problem. If you don't bind the grid to a recordsource until runtime, the column objects don't exist at design time, so there is no way to write code in their event-handlers.
It turns out that if you set the grid's AllowCellSelection to .F. (this property is new in VFP 8.0), then the individual textbox never gets focus, so it is always the grid's DblClick that fires. That makes it much easier to write code to trap the event, since you only have to write the code in one place, and the grid's DblClick is always available at design time.
What's more, the act of double-clicking also selects a record, so you can still use the record number to find out which row the user double-clicked on. (Unfortunately, that doesn't apply if they click in an empty portion of the grid.)
Mike
Mike Lewis
Edinburgh, Scotland
My Visual Foxpro web site: My Crystal Reports web site: