|
-
May 15th, 2010, 07:21 AM
#1
[RESOLVED] ToolStripTextBox and ToolStripMenuItem
I have in a menu a ToolStripTextBox where the user can enter a CASE NUMBER to FIND.
And I have a ToolStripMenuItem below that says QUICK FIND - clicking this will find the case you put in the textbox.
Tabbing out of the textbox puts you at this TOOLSTRIPMENUITEM so that ENTER on the keyboard will trigger the FIND.
I want to make it so that pressing ENTER while still in the textbox will trigger that same TOOLSTRIPMENUITEM action.
Do I have to trap keypresses or is there a more natural way to accomplish this?
-
May 15th, 2010, 07:37 AM
#2
Frenzied Member
Re: ToolStripTextBox and ToolStripMenuItem
capture the enter key of the textbox and call the button click event
vb Code:
Private Sub ToolStripTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripTextBox1.KeyDown If e.KeyCode = Keys.Enter Then Call Me.ToolStripButton1_Click(Me, Nothing) End If End Sub
-
May 15th, 2010, 08:23 AM
#3
Re: ToolStripTextBox and ToolStripMenuItem
 Originally Posted by szlamany
I have in a menu a ToolStripTextBox where the user can enter a CASE NUMBER to FIND.
And I have a ToolStripMenuItem below that says QUICK FIND - clicking this will find the case you put in the textbox.
Tabbing out of the textbox puts you at this TOOLSTRIPMENUITEM so that ENTER on the keyboard will trigger the FIND.
I want to make it so that pressing ENTER while still in the textbox will trigger that same TOOLSTRIPMENUITEM action.
Do I have to trap keypresses or is there a more natural way to accomplish this?
Put that code into a sub, then in the click event of the menuitem call the sub. In the keyup event of the textbox check for the enter key and if so, call that sub
-
May 15th, 2010, 09:03 AM
#4
Re: ToolStripTextBox and ToolStripMenuItem
Ok - I've trapped the KEYUP - and called the new SUB - but the menu stays open.
How do I collapse the menu?
-
May 15th, 2010, 09:46 AM
#5
Frenzied Member
Re: ToolStripTextBox and ToolStripMenuItem
First set the AutoClose property of the contextmenu to False in the Designer. Then Call the "Close" method of the menu to close it
-
May 15th, 2010, 09:53 AM
#6
Re: ToolStripTextBox and ToolStripMenuItem
It's not a context menu - it's a menustrip on the form itself - up top.
And I see no autoclose or close properties.
-
May 15th, 2010, 10:20 AM
#7
Re: ToolStripTextBox and ToolStripMenuItem
Got it - sorry for being so clueless!
Code:
Private Sub CaseViewMenuValue_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CaseViewMenuValue.KeyUp
If e.KeyCode = Keys.Enter Then
CaseViewMenu.DropDown.Close()
CaseRefresh()
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|