String msg = String.Format(" selected", item.Text)Ĭlick the File menu item to open the menu. Private void UpdateStatus(ToolStripItem item) control's Text property to the Text property of the This utility method assigns the value of a ToolStripItem Insert the UpdateStatus utility method definition into the form. Handles FileToolStripMenuItem.DropDownItemClicked Private Sub FileToolStripMenuItem_DropDownItemClicked( _īyVal e As ) _ ' called UpdateStatus, which updates the text displayed ' It passes the ClickedItem object to a utility method ' This method is the DropDownItemClicked event handler. Object sender, ToolStripItemClickedEventArgs e) Private void fileToolStripMenuItem_DropDownItemClicked( called UpdateStatus, which updates the text displayed It passes the ClickedItem object to a utility method This method is the DropDownItemClicked event handler. Insert the following code into the event handler. The Windows Forms Designer generates an event handler for the DropDownItemClicked event. Handle the DropDownItemClicked event to respond when the user selects a menu item.Ĭlick the File menu item that you created in the Creating a Standard Menu section.ĭouble-click the DropDownItemClicked event. The StatusStrip control automatically docks to the bottom of the form.Ĭlick the StatusStrip control's drop-down button and select StatusLabel to add a ToolStripStatusLabel control to the StatusStrip control. In the current example, menu items selected by the user are displayed in a StatusStrip control.įrom the Toolbox, drag a StatusStrip control onto your form. Use the StatusStrip control to display status for your Windows Forms applications. The MenuStrip control is populated with the standard menu items.Ĭlick the File menu item to see its default menu items and corresponding icons. The Windows Forms Designer can automatically populate a MenuStrip control with standard menu items.įrom the Toolbox, drag a MenuStrip control onto your form.Ĭlick the MenuStrip control's designer actions glyph ( ) and select Insert Standard Items. In the Windows Forms Designer, select the form. In Visual Studio, create a Windows application project called StandardMenuForm ( File > New > Project > Visual C# or Visual Basic > Classic Desktop > Windows Forms Application). You'll need Visual Studio to complete this walkthrough. To copy the code in this topic as a single listing, see How to: Provide Standard Menu Items to a Form. When you are finished, you will have a form with a standard menu that displays menu item selections in a StatusStrip control. The following tasks are illustrated in this walkthrough: The form also responds when a user selects a menu item. This walkthrough demonstrates how to use a MenuStrip control to create a standard menu. You can provide a standard menu for your forms with the MenuStrip control.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |