This is how I do it:
The form is a private datasession form used to choose an item from a list of
materials in a grid with several columns.
There is absolutely no code in either the KeyPress or the Double Click
events in any of the grid's textboxes. However, every time the user presses
the enter key or double clicks on any textbox on any row, either the
keypress or the double click events fire, being replaced by the chooseit
method on the form
** method name: INIT
thisform.binding()
** method name: BINDING
With thisform.grid1
For i = 1 to .columncount
BindEvent( .Columns(i).text1 , "DblClick" , thisform ,
"chooseit" )
BindEvent( .Columns(i).text1 , "KeyPress" , thisform ,
"chooseit" )
endfor
EndWith
** method name: CHOOSEIT
** the Lparameters line below is needed because that is what the KeyPress
event uses
LPARAMETERS nKeyCode, nShiftAltCtrl
AEvents(aCallingEvent,0)
if vartype(aCallingEvent) <> "U"
Do case
Case InList(Upper(aCallingEvent(2)),"KEYPRESS","DBLCLICK")
If not InList(Lastkey(),4,5,19,24) && arrow
keys
thisform.nMatId = materials.id && I just
pick the PK from the materials table
thisform.release()
endif
otherwise
endcase
endif
* ( the arrow keys line above prevents any of the methods to fire if the
user is just navigating the grid)
**method name: UNLOAD
return thisform.nMatId
Once the PK is obtained then I use it in the calling form as needed.
In my experience, bindevents is great !!
Rafael Copquin
----- Original Message -----
From: Rick Schummer
To: [EMAIL PROTECTED]
Sent: Thursday, July 24, 2008 12:47 AM
Subject: RE: Can I programattically set method code?
Ed's suggestion for BindEvents would be a runtime solution.
Are you trying to add code to the Click method at design time? (I could read
your question either
way <g>)
If so:
lcMethodCode = 'Messagebox("hi")'
oButton.WriteMethod("Click", lcMethodCode)
Rick
White Light Computing, Inc.
www.whitelightcomputing.com
www.swfox.net
www.rickschummer.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Vince Teachout
Sent: Wednesday, July 23, 2008 07:20 PM
To: [EMAIL PROTECTED]
Subject: Can I programattically set method code?
Is this possible?
In Development mode, I hover my mouse over a button on a form, then
without moving the mouse, type oButton = Sys(1270) in the command window
and hit enter. This creates an object pointer to the button, and I can
then do something like oButton.Caption = "Wow!", causing the the caption
on the form button to change.
My question is, can I do something similar, with code, in say, the
ClicK() method?
ie, something like: oButton.Click = 'Messagebox("hi")' (which,
obviously doesn't work, neither does obutton::click = 'Messagebox("hi")'
Anyway to do this? Thanks.
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.