Solved

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

Posted on 2007-11-20
3
2,003 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
call a controller action method from Global.asax in asp.net 1 27
VB.NET Textbox input validation 4 60
Amazon S3 .Net error 5 36
Upgrade code from VS 2010 to VS 2015 7 31
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 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