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

Grid Dblclick vs KeyPress event 1

Status
Not open for further replies.

yert33

Programmer
Feb 19, 2002
255
US
My grid's dblclick event is working fine. It returns the recno() of the current row and then set's it's own visiblity to .f.. The grid disappears.

I want the Enter key to do exactly what the dblclick code does so I put this in the Keypress event of the grid
Code:
If nKeyCode = 13
  this.dblclick()
endif

The Keypress causes all the dblclick code to execute but some elements of the grid remain on the screen; specifically the column header bar, the record selector column, the row border lines, the scroll bars and the row I just selected in highlight color. Everything but column lines and data and text.

Even if I put

this.visible=.f.

in the Keypress code, the grid remnants are still there.

BTW when I "call" the grid I set it's zorder(0) to put it on top of other controls in the form. Here's the "calling" code in a method of the form:

Code:
thisform.LockScreen = .T.

zap in (thisform.grdvoters.recordsource)

<<do stuff here to refresh the grid's recordsource cursor>>>

select (thisform.grdvoters.recordsource)
append from dbf( [crsTemp] )

go top in (thisform.grdvoters.recordsource)
thisform.grdvoters.refresh()
thisform.grdvoters.setfocus()
thisform.grdvoters.top=((thisform.nCurrentRow-1)*75)+165
thisform.grdvoters.zorder(0)
thisform.grdvoters.visible=.t.


thisform.LockScreen = .F.

Like I said, it works beautifully when dblclicked with the mouse, but leaves the remnants when Enter key is used.
Any idea why?


Thanks to all who bother to reply to my many recent posts. I keep looking to return the favor in the VFP forums but haven't seen any where I knew the answer first. Will keep looking.
 

Why not paste the DblClick code into the Keypress event? Not as a permanent solution, but it should help you debug it. If you find the problem, you can go back to the way you are doing it.

(In fact, a lot of people will say it's bad practice to call an event-handler explicitly. It would be better to write a custom method that does what you want, and to call it from both the Keypress and DblClick. But that's got nothing to do with your present problem.)

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I had tried that before but to make sure I just did what you suggested, Mike. Same result.

 
Hi yert,

The only difference in behaviour may be the standard behaviour of the keypress event (grid::keypress). Therefore try to put a NODEFAULT in there, when you hide the grid.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top