Solved

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

Posted on 2007-11-20
3
1,932 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks..
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now