Thêm Menus và chế biến Menu Sự kiện Microsoft Visual Studio 2005 cho phép bạn thêm các trình đơn và các mục trình đơn mẫu theo hai cách. Bạn có thể sử dụng Visual Studio 2005 tích hợp môi trường phát triển (IDE) và biên tập các trình đơn để tạo ra một menu đồ họa. | Adding Menus and Processing Menu Events Microsoft Visual Studio 2005 lets you add menus and menu items to a form in two ways. You can use the Visual Studio 2005 integrated development environment IDE and the menu editor to create a menu graphically. You can also write code that creates a MenuStrip object MenuStrip is a class defined in the Windows Forms library and then add ToolStripMenultem objects to it ToolStripMenultem is another class in the Windows Forms library . Laying out a menu is only half of the story. When a user clicks a command on a menu the user expects something to happen You activate the commands by trapping menu events and executing code in much the same way as you do for handling control events. Creating a Menu In the following exercise you will use the graphical approach to create menus for the Middleshire Bell Ringers Association application. We will cover how to manipulate and create menus programmatically later in this chapter. Create the File menu 1. Start Visual Studio 2005. 2. Open the BellRingers project located in the Microsoft Press Visual CSharp Step by Step Chapter 21 BellRingers folder in your My Documents folder. This is the Middleshire Bell Ringers application. It should be the same as the version that you completed in Chapter 20. 3. Display MemberForm in the Design View window. Click in the Solution Explorer and then click Designer on the View menu or double-click in the Solution Explorer . MemberForm appears. 4. In the Toolbox expand the Menus Toolbars category. Drag a MenuStrip control anywhere onto MemberForm. IMPORTANT Be sure to drop the MenuStrip control onto the form and not onto a control on the form. Some controls such as GroupBox can have their own menus and dropping a menu on such a control will create a menu for that control only. The control by default called menuStripl appears at the bottom of the form and a menu strip containing the caption Type Here is added to the top of the form. 5. .