[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?
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
Re: ToolStripTextBox and ToolStripMenuItem
Quote:
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
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?
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
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.
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