Link to home
Start Free TrialLog in
Avatar of leeal
leeal

asked on

HOW TO SKIP EVENTS?

Is it possible to stop some events from occuring?
For example, is it possible to skip the RowColChange event of the grid control when an arrow key is pressed?
ASKER CERTIFIED SOLUTION
Avatar of dirtdart
dirtdart

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leeal
leeal

ASKER

I am still not quite clear how it's done.

So does it mean that in:

private sub Grid1_KeyPress(KeyAscii as Integer)
   select case KeyAscii
   case 74
      ' do nothing for 'J'
   case 75
      ' do something for 'K'
   end select
end sub

It will skip the subsequent events when 'J' or 'K' is pressed, and NOT skip the subsequent events when any other keys are pressed? Automatically?

Does RowColChange event occur BEFORE or AFTER KeyPress/Up/Down event?

Specifically, what I want to do is to make the Grid NOT to un-highlight the selected regions when arrow keys are pressed.
Actually, it's better to use the KeyDown event.  It intercepts all keys
pressed before they are sent to the form or control for processing.  So, if
you put this code in:

Sub DBGrid1_KeyDown(Keycode As Integer)

If Keycode
= vbRightArrow Then Keycode = 0

End Sub

Then it would intercept that
keypress, and if it is the right arrow, it would turn the keycode into
null, so that the control would think that no key had been pressed.  A list
of keycode constants (vbRightArrow, vbLeftArrow, etc) is available in the
VB help file.

So, RowColChange will fire After the KeyDown and Keypress
events, but before the KeyUp event.

Sorry it took so long for the response, but I was just now able to get on to Expert's Exchange.  Guess they were having server problems.
Avatar of leeal

ASKER

Thanks.