Wrox Programmer Forums
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 9th, 2005, 03:52 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default ContextMenuStrip problems


I have a ToolStripTextBox in a ContextMenuStrip in a 2.0 windows form. I want to type text into it, and then hit enter, and then do what I want to do. The problem is is that the textbox doesn't recognize the KeyUp event when Enter is hit. AllowReturn is false, on the form KeyPreview is true. The way that I did it was use a keyup event on the contextmenustrip which works, but isn't the way I want to do it.

How can I get that textbox to recognize the Enter key? I should also note that the contextmenustrip only recognizes the enter key on the number pad and not the main enter key.


Old November 17th, 2005, 10:27 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma

Interesting problem you have run into here. Well when you press enter it is recieved as a window close command
by the context menu control window. That is why no key ups are ever recieved on this window 'cause as soon as enter key is pressed Down (it doesnt wait for it to get back Up) context meny window starts packing up and once its closed there are no controls to recieve the KeyUps.

U can counter this beheviour if u refuse to close the context window down on Enter key- in the Closing event of ContextMenuStrip control. (u can do that by assignin true to Cancel property of ToolStripDropDownClosingEventArgs parameter). while you are keeping the context menu control window from closing itself you will get all the events you want. once you are though you can close the window yourself.

Ankur Verma

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems already! KennySargent BOOK: Professional XNA Programming 2nd Edition ISBN: 978-0-470-26128-6 4 April 7th, 2008 03:36 AM
c problems saurabh1983in C++ Programming 6 November 29th, 2005 04:23 AM
validate.asp problems and logon.asp problems p2ptolu Classic ASP Databases 0 February 16th, 2005 02:34 PM
Problems kilika Javascript 1 October 3rd, 2003 02:42 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.