![]() To do so, first we set ContextMenuStrip property and then use call the Show method to display the ContextMenuStrip. Once the ContextMenuStrip control is ready with its properties, the next step is to add the ContextMenuStrip to a Form. PopupMenu.Font = New Font( "Georgia", 16) PopupMenu.Font = new Font( "Georgia", 16) The following code snippet sets background color, foreground color, Text, Name, and Font properties of a ContextMenuStrip. In the next step, you may set properties of a ContextMenuStrip control. The following code snippet creates a ContextMenuStrip control object.ĬontextMenuStrip PopupMenu = new ContextMenuStrip() Even though you can create a ContextMenuStrip at run-time, it is recommended you create at design-time and then set the properties and methods at run-time.įirst step to create a dynamic ContextMenuStrip is to create an instance of ContextMenuStrip class. We can also create context menus at run-time. I add two menu items and two sub menu items. As soon as you select a menu item, you will see automatically sub menu items areas are editable and you can keep going as many levels you like. If you notice in Figure 2, I type couple of menu items. If you noticed in Figure 1, first item of the ContextMenuStrip has text Type Here. Once a ContextMenuStrip is on the Form, you can add menu items and set its properties and events. After you drag and drop a ContextMenuStrip on a Form, the ContextMenuStrip1 is added to the Form and looks like Figure 1. To create a ContextMenuStrip control at design-time, you simply drag and drop a ContextMenuStrip control from Toolbox onto a Form in Visual Studio. In this article, we will discuss how to build context menu enabled Windows applications using ContextMenuStrip control in Visual Studio 2010. NET 4.0, the ContextMenu control is replaced with the ContextMenuStrip control. NET, the context menu functionality was provided by the ContextMenu control. A context menu appears when you right click on a Form or on a control. A context menu is also known as a popup menu. ![]() ![]() The ContextMenuStrip control provides functionality of context menus in Visual Studio 2010 and.
0 Comments
Leave a Reply. |