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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.