Solved

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

Posted on 2007-11-20
3
2,055 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PowerShell Core for Advanced Linux Administrators

Understand advanced principals around Powershell Core with a focus on the Linux Administrator.  This course covers how to administer numerous environments across multiple platforms including Linux, Azure, AWS, and Google Cloud from a single shell instance.

Question has a verified solution.

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

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 …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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