Stoffel85 Posted March 14, 2006 Posted March 14, 2006 Hi, I want to make a search bar simular to the firefox search bar. So I want it to close when I press Escape. The problem is, when I press Escape, it won't run the KeyUp, KeyDown or KeyPress sequence. I tried it on the toolbar, the textbox in the toolbar and on the button, none work. Private Sub tlTxtSomething_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tlCategorie.KeyDown If (e.KeyCode = Keys.Escape) Then tlSearch.Visible = False End If End Sub Quote
Leaders snarfblam Posted March 15, 2006 Leaders Posted March 15, 2006 Are you using a ToolBar or a ToolStrip? I don't believe that a ToolBar ever actually receives focus, and a control must have focus to receive keyboard input. If there are controls on the toolbar (and I'm guessing that you have a textbox), you can use the control's keydown/keypress events. If you are using a ToolStrip, and a control within the ToolStrip has focus, the ToolStrip will also receive the keyboard input. Another possibility is to set the containing form's KeyPreview property to true and handle keyboard events for the form. Quote [sIGPIC]e[/sIGPIC]
Stoffel85 Posted March 15, 2006 Author Posted March 15, 2006 Thanks for your reply. It is a ToolStrip (I'm using VS2005). It works when I use the KeyUp event in my form. But when I do the same in the ToolStrip KeyUp event, nothing happens. If there's no other way to let that work, then I'll use the KeyUp event in my form. Thanks already Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.