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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to add a method to a grid built on the fly

Status
Not open for further replies.

ross6720

Programmer
May 3, 2004
15
US
I am building a grid on the fly. I want to put a command in the dblclick() of each column that will select the record and close the form that has the grid. How can I add a method to a grid after it is defined? I have looked at WriteMethod() but this does not work or I am doing something it doesn't like.

thanks,
Ray Ross
 
VFP8 or VFP9 you can use BindEvent() function to bind event of DblClick() event of the Control stored in columns. Something like:

Code:
*** After you define Grid

FOR asd= 1 TO thisform.Grid1.ColumnCount
    oColumn = thisform.Grid1.Columns(asd)
    oControl= oColumn.CurrentCuntrol
    BINDEVENT(oColumn,"DBLCLICK",thisform,"ColumnClick",1) && See help for last result
NEXT

you must have a method in the form named ColumnClick, There you can hadle DblClick event.
If you want to know what specific column receive DblClick you can use AEVENTS() function. Don't forget to UNBINDEVENT before you close the form.




Borislav Borissov
 
this is what I tried:

for asd = 1 to thisform.gridSystems.columncount
oColumn = thisform.gridSystems.Columns(asd)
oControl = oColumn.CurrentControl
BINDEVENT(oColumn,"dblclick",thisform,"columnclick",1)
next

err = "Function argument value, type, or count is invalid."

I created the "columnclick" method on the form that contains the grid. "Dblclick" is the 'column.text' method that I am trying to fill with code.

What is wrong with what I am trying?

thanks
 
My mistake oControl is just a String with the name of the control, not the control itself.
Code:
for asd = 1 to thisform.gridSystems.columncount
      BINDEVENT(thisform.gridSystems.Columns(asd).Text1,"dblclick",thisform,"columnclick",1)
next

Borislav Borissov
 
Thank you, Borislav, for the correction. Works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top