Click here to Skip to main content
11,929,675 members (59,912 online)
Click here to Skip to main content
Add your own
alternative version


218 bookmarked

Super Context Menu Strip

, 5 Oct 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
How to build a context menu that displays any group of controls
Figure 1: You can put any group of controls on the pop-up context menu.


Long time ago, I wondered how Microsoft Access put an Edit control on the context menu!!! Then I got another idea… why we do not use any control(s) on the context menu??? This will make the user interface easier to use and learn and even faster. The good news here is that, you can make it the same way you design a user control or a form using the Visual Studio designer.


At first, I thought we could customize the Menu. Then I discovered that this is very hard and maybe impossible. I tried to make use of the Form, but this is not the right choice because when we show it, the parent form loses its focus. A context menu shouldn't cause that. Luckily, I found a very good article "Simple Pop-up Control" by Lukasz Swiatkowski. This article shows how to display a pop up control using the ToolStripDropDown class. Then I said, "I found it." I used that idea to make my idea: a context menu that contains any group of controls. And now, I have a new and easier implementation.

How It Works

SuperContextMenuStrip is based on ContextMenuStrip which adds a user control to a ToolStripControlHost then adds the host as an item to the menu.

Using the Code

  1. Add a user control to your project and put any group of controls in it, the way you like, but make them public so that you can add event handlers to them.
  2. Override ProcessDialogKey in your user control and make sure it is as shown in the sample code.
  3. Please have a look at the main from source code, you will find it so easy to use it.

Known Bugs

I still have these bugs but I am working on them. If you have any idea how to solve these bugs, please help me.

  1. If the pop-up menu is shown and the user clicks a MenuStrip, a ToolStrip or an item on them, it does not hide. It needs two clicks to hide!!!
  2. The System.Windows.Forms.ComboBox class behaves in a strange way. It closes the container when the user clicks on the part of the combo box's dropdown list that sticks out of the container area. So, make sure that the dropdown list is totally inside the area.

Suggested Add-on Features and Ideas

  • Add a small x button to close it
  • Easily move it
  • Allow resizing
    (But I don't recommend these changes, because they violate the concept of a menu; but you may find it a good idea.)
  • You can use it to implement custom tool tip, intellisense menus like Visual Studio.


  • October 2009
    • Completely changed the structure (AGAIN) to make it easier to use
  • June 2008
    • Completely changed the structure to make it easier to use
    • Solved the tab bug
  • December 2007
    • First release


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Hany Badrous
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralYeah Pin
Yves11-Aug-15 7:17
memberYves11-Aug-15 7:17 
AnswerAn ugly way to fix the two clicks bug.But it works. Pin
ilzhuzhu7-Sep-14 7:34
memberilzhuzhu7-Sep-14 7:34 
QuestionCan this Control implemented in WPF Pin
praveenkumaras10-Aug-14 9:10
memberpraveenkumaras10-Aug-14 9:10 
QuestionEvents Pin
Lonnie Nunweiler24-Apr-13 2:57
memberLonnie Nunweiler24-Apr-13 2:57 
QuestionNested Popup Possible? Pin
Member 22710476-Mar-13 16:58
memberMember 22710476-Mar-13 16:58 
GeneralMy vote of 5 Pin
Jacobkingsly18-Feb-13 19:28
memberJacobkingsly18-Feb-13 19:28 
Questionhow to make it resizable !! Pin
A7mad_24-Oct-12 1:09
memberA7mad_24-Oct-12 1:09 
GeneralSuper GREAT !! Pin
Mazen el Senih23-Mar-12 6:31
memberMazen el Senih23-Mar-12 6:31 
GeneralMy vote of 5 Pin
zaheer_sagitarius28-Feb-12 3:52
memberzaheer_sagitarius28-Feb-12 3:52 
QuestionAbsolutely Great! Pin
MikeDaMan259421-Jan-12 10:05
memberMikeDaMan259421-Jan-12 10:05 
GeneralThis Control Has Changed ALL My Programs Pin
Member 809931229-Dec-11 6:11
memberMember 809931229-Dec-11 6:11 
BugThe solution of the 2nd bug Pin
grrrrr12-Dec-11 4:15
membergrrrrr12-Dec-11 4:15 
Questionthe control I want to pop is a dynamic one Pin
idn197823-Nov-11 16:21
memberidn197823-Nov-11 16:21 
GeneralMy vote of 5 Pin
aaroncampf13-May-11 20:49
memberaaroncampf13-May-11 20:49 
GeneralGreat!!! Pin
minhhieu_dotnet3-Nov-10 1:07
memberminhhieu_dotnet3-Nov-10 1:07 
GeneralRe: Great!!! Pin
Hany Badrous3-Nov-10 16:22
memberHany Badrous3-Nov-10 16:22 
QuestionHow to remove dropshadow? Pin
Edmilson S. Teixeira10-Aug-10 12:14
memberEdmilson S. Teixeira10-Aug-10 12:14 
AnswerRe: How to remove dropshadow? Pin
Edmilson S. Teixeira13-Aug-10 12:28
memberEdmilson S. Teixeira13-Aug-10 12:28 
QuestionContextMenuStrip problem Pin
Martin Macak26-Feb-10 9:46
memberMartin Macak26-Feb-10 9:46 
Generala bug on example project Pin
mheidari11-Jul-09 21:55
membermheidari11-Jul-09 21:55 
GeneralRe: a bug on example project Pin
Hany Badrous12-Jul-09 3:48
memberHany Badrous12-Jul-09 3:48 
GeneralRe: a bug on example project Pin
mheidari12-Aug-09 2:42
membermheidari12-Aug-09 2:42 
AnswerPossible solution for the two clicks to hide bug [modified] Pin
timbo90000114-Jan-09 4:46
membertimbo90000114-Jan-09 4:46 
GeneralRe: Possible solution for the two clicks to hide bug Pin
T.Rankill17-Feb-10 12:39
memberT.Rankill17-Feb-10 12:39 
GeneralRe: Possible solution for the two clicks to hide bug [modified] Pin
dreamgarden3-Apr-14 10:08
memberdreamgarden3-Apr-14 10:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151126.1 | Last Updated 5 Oct 2009
Article Copyright 2008 by Hany Badrous
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid