Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-20
3
Medium Priority
?
2,120 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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 …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

963 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