Home > Articles > Programming > Windows Programming

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

Like this article? We recommend

MenuStrip (replaces MainMenu)

Think of the MenuStrip as a more flexible MainMenu control. When working with a MainMenu control, you have access to one kind of insert—a MenuItem control. However, modern user interfaces don’t rely on MenuItem controls alone. You might see other controls displayed within a menu to make it more flexible and easier to use. The MenuStrip fixes this problem. You can use the MenuItem, TextBox, and ComboBox controls as top-level menu entries. A menu can therefore contain choices such as a language selection, or freeform text entries such as a search value. Second and greater level entries can include the MenuItem, ComboBox, Separator, and TextBox controls, as shown in Figure 4.

Figure 4

Figure 4 Think of the MenuStrip as a very flexible form of the MainMenu control.

The default control is still the MenuItem. To choose a different control, click the down arrow (now found in every menu entry) to get the list shown in Figure 4. From the drop-down list, choose the control you want to use. If you decide that you want to use a different control in that position, simply right-click the entry and choose Convert To > new control from the context menu (where new control is the type of control that you want to use).

Configuring a MenuStrip works the same as it always has for MenuItem controls. You do have additional choices, but you don’t have to use them. To configure all other controls, select the parent menu level. Select the DropDownItems property in the properties window and click the ellipsis (...). The Items Collection Editor dialog box appears, as shown in Figure 5.

Figure 5

Figure 5 Use the Items Collection Editor to change the properties of menu control alternatives.

Notice that in the left pane, the Items Collection Editor displays a list of menu items found in the parent control. When you select one of the items, its properties appear in the right pane. Choose a property, and you can edit as you normally would in the properties window. For example, you’d normally add entries to the Items property for a combo box.

  • + Share This
  • 🔖 Save To Your Account