Event doesn't start when Escape key is hit

stoffel85
03-15-2006, 02:35 AM
Hi

I am trying to make a toolbar that goes away when the escape key is hit (if something on the toolbar has focus. But whatever I try (keyevents with toolbar, textbox, button) none work.

Private Sub tlTxtBleh_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles tlTitel.KeyPress
If (Asc(e.KeyChar) = Keys.Escape) Then
toolZoeken.Visible = False
End If
End Sub


I also tried the KeyUp, KeyDown events, those don't work either.
Any idea why?


Edit: Sorry, wrong place. Can anybody move it?
Edit: This is a doublepost, it may be deleted. I couldn't find my other thread, but I just found it: http://dotnetforums.net/showthread.php?p=454624#post454624

IUnknown
03-18-2006, 04:22 PM
Try the KeyDown or KeyUp.

jo0ls
03-18-2006, 05:27 PM
Some keys count as navigation keys and the keypress isn't handled.
A workaround: create a custom control, inherit from the control you want, override isInputKey and return true for the extra keys you want to handle. Then use the custom control instead of the standard control.
Toolbars don't get focus though, so your not going to catch any keypresses on the toolbar itself.


Public Class ButtonMod
Inherits Button
'
Protected Overrides Function IsInputKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Escape Then Return True
End Function
'
End Class

IUnknown
03-18-2006, 07:19 PM
Ta jo0ls. I need some glasses. :o

stoffel85
03-21-2006, 03:13 AM
Thanks for your replies, I'll try it out

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum