Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

ContextMenuStrip (replaces ContextMenu)

Many users are now accustomed to the "right-click everywhere" method of learning to use an application and the shortcuts it can provide. Right-clicking displays a context menu that describes what you can do with the selected object. Often, using context menus means that the user can avoid accessing menus and keeping a large number of toolbars visible onscreen. Context menus are extremely efficient from a "screen real estate" perspective because they keep features hidden until needed. Consequently, many developers realized the value of the ContextMenu control in previous versions of Visual Studio quite quickly.

You might wonder why Microsoft has replaced a valuable and popular control with a newcomer. The ContextMenuStrip control takes a good idea and makes it better. It works just like the ContextMenu control. You still attach a ContextMenuStrip control to another user control by changing that control’s ContextMenuStrip property. However, Microsoft has substantially improved the features you can add to a ContextMenuStrip control, as shown in Figure 1.

Figure 1

Figure 1 The ContextMenuStrip control provides greater functionality than the ContextMenu.

You can create a standard menu entry for the ContextMenuStrip control. However, you can also create a combo box, separator, or text box. These added controls make it possible to extend the functionality of a context menu considerably. For example, by adding a combo box entry to the context menu, you can let the user choose from entries he or she has provided for that text box in the past. In this case, you’re not only making things faster for the user by letting him or her choose a quick entry for a text box where a standard entry isn’t available, but you’re also customizing the application in a new way.

  • + Share This
  • 🔖 Save To Your Account