Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grid Double Click

Status
Not open for further replies.

rommeltm00

Programmer
Feb 16, 2006
56
PH
I have a database that automatically loads on a grid

ex

use employee
structure of employee is employeecode,name,address,city,region,etc

do form search
the search form will automatically filled all records on employee table
in this sequence
employeecode,name,address,city,region,country,zipcode


now i want to make a double click event on the name,or on city or even all the fields on the grid

how can i do it, pls help

 
You need to write code in the DblClick event of the textbox within the grid's columns. Note that this is not the same as the grid's DblClick. The grid contains columns; each column contains a textbox (by default). It is that textbox where you must add your code.

When the DblClick fires, the record pointer will be at the record whose grid row is currently selected. Within your code, you can access that record to process the data in whatever way you want.

I hope this helps.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
now i want to make a double click event on the name,or on city or even all the fields on the grid

You did not say which version of VFP you are using.

In version 8 and later, you can use BindEvent() to handle it like this:

Code:
FOR lnCol = 1 TO This.ColumnCount
  loColumn = This.Columns[ lnCol ]
  FOR EACH loControl IN loColumn.Controls
    IF LOWER( loControl.BaseClass ) = 'header'
      BINDEVENT( loControl, 'Click', This, 'SortGrid' )
    ELSE
      IF PEMSTATUS( loControl, [dblClick], 5 )      
        BINDEVENT( loControl, 'dblClick', This, 'dblClick' )  
      ENDIF
      IF PEMSTATUS( loControl, [RightClick], 5 )      
        BINDEVENT( loControl, 'Click', This, 'RightClick' )  
      ENDIF
    ENDIF
  ENDFOR
ENDFOR

Of course, if you set the grid's AllowCellSelection property to .F., the grid's dblClick will fire instead of that of the contained controls - no code required :)

Marcia G. Akins
 
Thank you for the response, the allowcellselection = .f. do the trick, again thank you to mike and marcia, God Bless.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top