Solved

C# How to put a Labeled textbox Control inside of a ContextMenu

Posted on 2007-11-20
3
1,985 Views
Last Modified: 2012-06-27
I would like to be able to rightclick on a groupBox and get some menu Options as well as one of the options be labeled and have a Textbox where I can type something and press enter to activate an event

Any help is appreciated
Thanks
0
Comment
Question by:scogger1974
  • 2
3 Comments
 
LVL 11

Expert Comment

by:Babycorn-Starfish
ID: 20326508
Thats pretty straight forward.

Drag on, from the control toolbox, a context menu strip onto your GroupBox, it'll look like you added a menu to your form, don't worry. Select your group box control and in the ContextMenuStrip property select the name of the context menu you just added
0
 
LVL 11

Accepted Solution

by:
Babycorn-Starfish earned 500 total points
ID: 20326532
Then..
 
select the context menu item, it'll appear underneath your form in the component tray, this will display it and again it will look like you added a menu to your form. If you clikc on the white box in the context menu an arrow will appear, it's a combo box, click on this and you can add a text box. You won't be able to have a label unforutnately, you'll have to use the text property of the text box to convey any meaning. Next select the textbox and click on the lightning bolt icon on the properties tab to display the events, handle the KeyPress event by double clicking in the empty space next to its name and use code similar to below to handle your event:


 private void toolStripTextBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch ((Keys)e.KeyChar)
            {
                case Keys.Enter:
                    {
                        MessageBox.Show("Enter Pressed");
                        break;
                    }
                default:
                    {
                        return;
                    }
            }
        }

Open in new window

0
 
LVL 1

Author Closing Comment

by:scogger1974
ID: 31410188
Thanks..
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question