Menustrip and winformmenustrip in the Winform menu
There must be menus in a form. You can directly use the menu components or buttons (buttons cannot display cascading menus ).
The following describes the menus.
1. Menustrip
This menu is the most commonly used one. Drag a menustrip from the toolbar to the form.
(1) The location setting is the Dock attribute. You can use the code in the load event of the form or directly set it in the menu attribute, usually there are LEFT on the LEFT, RIGHT on the RIGHT, BOTTOM, TOP and so on. It is placed on the top of the form by default. Of course, you can set it according to your habits.
(2) menu item settings can be directly added from the Items set in the menu. Of course, there are many settings in the menu so that the menu can better meet developers' requirements. Another method is to directly input the data on Menustrip. For example,
If you enter the system (& F) in the text field to indicate that you want to enable the shortcut key, for example, the system (F) in the text field is like this, but you still need to set it, right is the following settings. You can set both of them.
This field can be set when the menu is set in the items set.
This item is set in the Property Section after you select the menu item. The modifier Ctrl and key K indicate that the shortcut key is Ctrl + F ←, Which is set according to the developer's wishes.
After setting a series of system menus, you need to write the menu logic. You can double-click the menu item to switch to the Code Section. The cursor is also displayed in the double-click event method, write the operation you need in it. Generally, you can call other subforms.
If you think this is unpleasant, the operations in it may be used in multiple places, there are two ways: one is to write the operations in it into a private method, then you need to call it locally. Second, write a method similar to the following. Select this method from Click Event on the event tab of the menu item. These two methods are actually exactly the same.
Private void ShowNewForm (object sender, EventArgs e) {xxxxxxx}