Results 1 to 7 of 7

Thread: [RESOLVED] ToolStripTextBox and ToolStripMenuItem

  1. #1

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Resolved [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?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  2. #2
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    Re: ToolStripTextBox and ToolStripMenuItem

    capture the enter key of the textbox and call the button click event
    vb Code:
    1. Private Sub ToolStripTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripTextBox1.KeyDown
    2. If e.KeyCode = Keys.Enter Then
    3.             Call Me.ToolStripButton1_Click(Me, Nothing)
    4.         End If
    5. End Sub

  3. #3
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: ToolStripTextBox and ToolStripMenuItem

    Quote Originally Posted by szlamany View Post
    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
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  4. #4

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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?

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5
    Frenzied Member
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,158

    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

  6. #6

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  7. #7

    Thread Starter
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    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

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width