Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Leaders
Posted
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.
[sIGPIC]e[/sIGPIC]
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...