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

KeyPreview equivalent for Grids 1

Status
Not open for further replies.

REDixon

Programmer
Mar 25, 2002
7
0
0
US
Does anyone have suggetions on how to emulate a KeyPreview/KeyPressed combo for a grid? I would like to be able to setup actions for double-click and right-click without having to attach code to each columns textbox.

Rodney
rodney_dixon@mckee.com
 
I forgot to mention, this is running under VFP7.


Rodney
McKee Foods Corporation
rodney.dixon@mckee.com
 
As far as I know you are out of luck on this one.
The textbox always gets the clicks first.

What I did was create a set of classes textbox, combobox etc for use in grids and put the code in the classes.

Then I always drop my class in each column. The code in the class calls a standardized method in my grid class which then does whatever it is that needs doing.

If you call the method in the grid as follows then the method gets a reference to the object that called it which is handy for determing which column the text box was in.

In the text box doubleclick method

this.parent.parent.grddblclick(this)



 
Hi

KeyPreview and KeyPressed will not get activated for mouse rightclick or double click. KeyPress of KeyBoard can be caught thru the KeyPress event, when the grid is in focus.

Example..
myForm.KeyPreview = .t.

myForm.KeyPress Event
*********************
IF ThisForm.ActiveControl = ThisForm.myGrid1
WAIT WINDOW "Key pressed while in Grid"
ENDIF
DODEFAULT()

YOu can also trap the function keys pressed while in Grid the same way, by checking the nkeyCode value.

:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
fluteplr: That is what I thought. The KeyPreview/KeyPressed combo for all containers would be very nice.

ramani: Thanks for the tip.

Rodney
McKee Foods Corporation
rodney.dixon@mckee.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top