Menu control in windows form

Элемент управления ToolBar (Windows Forms) ToolBar Control (Windows Forms)

Элемент управления ToolStrip заменяет элемент управления ToolBar и расширяет его функциональные возможности; однако при необходимости элемент управления ToolBar можно сохранить для обратной совместимости и использования в будущем. The ToolStrip control replaces and adds functionality to the ToolBar control; however, the ToolBar control is retained for both backward compatibility and future use, if you choose.

Элемент управления Windows Forms ToolBar используется в формах в качестве панели управления, на которой выводится ряд раскрывающихся меню и кнопок с растровыми изображениями, активирующих команды. The Windows Forms ToolBar control is used on forms as a control bar that displays a row of drop-down menus and bitmapped buttons that activate commands. То есть щелчок по кнопке на панели инструментов эквивалентен выбору команды в меню. Thus, clicking a toolbar button is equivalent to choosing a menu command. Для кнопок можно настроить режим поведения кнопок, раскрывающихся меню или разделителей. The buttons can be configured to appear and behave as push buttons, drop-down menus, or separators. Обычно на панели инструментов содержатся кнопки и меню, соответствующие элементам в структуре меню приложения, которые предоставляют быстрый доступ к наиболее часто используемым в приложении функциям и командам. Typically, a toolbar contains buttons and menus that correspond to items in an application’s menu structure, providing quick access to an application’s most frequently used functions and commands.

Свойство DropDownMenu элемента управления ToolBar принимает в качестве ссылки экземпляр класса ContextMenu. The ToolBar control’s DropDownMenu property takes an instance of the ContextMenu class as a reference. При использовании подобных кнопок на панели инструментов приложения будьте внимательны в выборе передаваемой ссылки, так как это свойство принимает любой объект, наследуемый от класса Menu. Carefully consider the reference you pass when implementing this sort of button on toolbars in your application, as the property will accept any object that inherits from the Menu class.

в этом разделе In This Section

Общие сведения об элементе управления ToolBar ToolBar Control Overview
Общие понятия, связанные с элементом управления ToolBar , который позволяет разрабатывать пользовательские панели инструментов. Introduces the general concepts of the ToolBar control, which allows you to design custom toolbars that your users can work with.

Практическое руководство. Добавление кнопок в элемент управления ToolBar How to: Add Buttons to a ToolBar Control
Описываются способы добавления кнопок в элемент управления ToolBar . Describes how to add buttons to a ToolBar control.

Практическое руководство. Определение значка для кнопки элемента управления ToolBar How to: Define an Icon for a ToolBar Button
Описываются способы отображения значков на кнопках элемента управления ToolBar . Describes how to display icons within a ToolBar control’s buttons.

Практическое руководство. Генерирование событий меню для кнопок элемента управления Toolbar How to: Trigger Menu Events for Toolbar Buttons
Инструкции по написанию кода для определения нажатой пользователем кнопки элемента управления ToolBar . Gives directions on writing code to interpret which button the user clicks in a ToolBar control.

Справочник Reference

Класс ToolBar ToolBar class
Справочная информация о классе и его членах. Provides reference information on the class and its members.

Элементы управления для использования в формах Windows Forms Controls to Use on Windows Forms
Полный список элементов управления Windows Forms со ссылками на информацию об их применении. Provides a complete list of Windows Forms controls, with links to information on their use.

Элемент управления ToolStrip ToolStrip Control
Описываются панели инструментов, на которых можно разместить меню, элементы управления и пользовательские элементы управления в приложениях Windows Forms. Describes toolbars that can host menus, controls, and user controls in Windows Forms applications.

Читайте также:  Что делать если забыл пароль от ноутбука acer windows 10

Walkthrough: Providing Standard Menu Items to a Form

You can provide a standard menu for your forms with the MenuStrip control.

This walkthrough demonstrates how to use a MenuStrip control to create a standard menu. The form also responds when a user selects a menu item. The following tasks are illustrated in this walkthrough:

Creating a Windows Forms project.

Creating a standard menu.

Creating a StatusStrip control.

Handling menu item selection.

When you are finished, you will have a form with a standard menu that displays menu item selections in a StatusStrip control.

To copy the code in this topic as a single listing, see How to: Provide Standard Menu Items to a Form.

Prerequisites

You’ll need Visual Studio to complete this walkthrough.

Create the project

In Visual Studio, create a Windows application project called StandardMenuForm (File > New > Project > Visual C# or Visual Basic > Classic Desktop > Windows Forms Application).

In the Windows Forms Designer, select the form.

Create a standard menu

The Windows Forms Designer can automatically populate a MenuStrip control with standard menu items.

From the Toolbox, drag a MenuStrip control onto your form.

Click the MenuStrip control’s designer actions glyph () and select Insert Standard Items.

The MenuStrip control is populated with the standard menu items.

Click the File menu item to see its default menu items and corresponding icons.

Create a StatusStrip control

Use the StatusStrip control to display status for your Windows Forms applications. In the current example, menu items selected by the user are displayed in a StatusStrip control.

From the Toolbox, drag a StatusStrip control onto your form.

The StatusStrip control automatically docks to the bottom of the form.

Click the StatusStrip control’s drop-down button and select StatusLabel to add a ToolStripStatusLabel control to the StatusStrip control.

Handle item selection

Handle the DropDownItemClicked event to respond when the user selects a menu item.

Click the File menu item that you created in the Creating a Standard Menu section.

In the Properties window, click Events.

The Windows Forms Designer generates an event handler for the DropDownItemClicked event.

Insert the following code into the event handler.

Insert the UpdateStatus utility method definition into the form.

Checkpoint -test your form

Press F5 to compile and run your form.

Click the File menu item to open the menu.

On the File menu, click one of the items to select it.

The StatusStrip control displays the selected item.

Next steps

In this walkthrough, you have created a form with a standard menu. You can use the ToolStrip family of controls for many other purposes:

Create shortcut menus for your controls with ContextMenuStrip. For more information, see ContextMenu Component Overview.

Create a multiple document interface (MDI) form with docking ToolStrip controls. For more information, see Walkthrough: Creating an MDI Form with Menu Merging and ToolStrip Controls.

Give your ToolStrip controls a professional appearance. For more information, see How to: Set the ToolStrip Renderer for an Application.

Controls to Use on Windows Forms

The following is an alphabetic list of controls and components that can be used on Windows Forms. In addition to the Windows Forms controls covered in this section, you can add ActiveX and custom controls to Windows Forms. If you do not find the control you need listed here, you can also create your own. For details, see Developing Windows Forms Controls at Design Time. For more information about choosing the control you need, see Windows Forms Controls by Function.

Visual Basic controls are based on classes provided by the .NET Framework.

In This Section

Windows Forms Controls by Function
Lists and describes Windows Forms controls based on the .NET Framework.

Читайте также:  Поиск по файловой системе linux

Controls with Built-In Owner-Drawing Support
Describes how to alter aspects of a control’s appearance that are not available through properties.

BackgroundWorker Component
Enables a form or control to run an operation asynchronously.

BindingNavigator Control
Provides the navigation and manipulation user interface (UI) for controls that are bound to data.

BindingSource Component
Encapsulates a data source for binding to controls.

Button Control
Presents a standard button that the user can click to perform actions.

CheckBox Control
Indicates whether a condition is on or off.

CheckedListBox Control
Displays a list of items with a check box next to each item.

ColorDialog Component
Allows the user to select a color from a palette in a pre-configured dialog box and to add custom colors to that palette.

ComboBox Control
Displays data in a drop-down combo box.

ContextMenu Component
Provides users with an easily accessible menu of frequently used commands that are associated with the selected object. Although ContextMenuStrip replaces and adds functionality to the ContextMenu control of previous versions, ContextMenu is retained for both backward compatibility and future use if so desired.

ContextMenuStrip Control
Represents a shortcut menu. Although ContextMenuStrip replaces and adds functionality to the ContextMenu control of previous versions, ContextMenu is retained for both backward compatibility and future use if so desired.

DataGrid Control
Displays tabular data from a dataset and allows for updates to the data source.

DataGridView Control
Provides a flexible, extensible system for displaying and editing tabular data.

DateTimePicker Control
Allows the user to select a single item from a list of dates or times.

Dialog-Box Controls and Components
Describes a set of controls that allow users to perform standard interactions with the application or system.

DomainUpDown Control
Displays text strings that a user can browse through and select from.

ErrorProvider Component
Displays error information to the user in a non-intrusive way.

FileDialog Class Provides base-class functionality for file dialog boxes.

FlowLayoutPanel Control
Represents a panel that dynamically lays out its contents horizontally or vertically.

FolderBrowserDialog Component
Displays an interface with which users can browse and select a directory or create a new one.

FontDialog Component
Exposes the fonts that are currently installed on the system.

GroupBox Control
Provides an identifiable grouping for other controls.

HelpProvider Component
Associates an HTML Help file with a Windows-based application.

HScrollBar and VScrollBar Controls
Provide navigation through a list of items or a large amount of information by scrolling either horizontally or vertically within an application or control.

ImageList Component
Displays images on other controls.

Label Control
Displays text that cannot be edited by the user.

LinkLabel Control
Allows you to add Web-style links to Windows Forms applications.

ListBox Control
Allows the user to select one or more items from a predefined list.

ListView Control
Displays a list of items with icons, in the manner of Windows Explorer.

MainMenu Component
Displays a menu at run time. Although MenuStrip replaces and adds functionality to the MainMenu control of previous versions, MainMenu is retained for both backward compatibility and future use if you choose.

MaskedTextBox Control
Constrains the format of user input in a form.

MenuStrip Control
Provides a menu system for a form. Although MenuStrip replaces and adds functionality to the MainMenu control of previous versions, MainMenu is retained for both backward compatibility and future use if you choose.

MonthCalendar Control
Presents an intuitive graphical interface for users to view and set date information.

NotifyIcon Component
Displays icons for processes that run in the background and would not otherwise have user interfaces.

NumericUpDown Control
Displays numerals that a user can browse through and select from.

OpenFileDialog Component
Allows users to open files by using a pre-configured dialog box.

PageSetupDialog Component
Sets page details for printing through a pre-configured dialog box.

Panel Control
Provide an identifiable grouping for other controls, and allows for scrolling.

Читайте также:  Linux live usb creator from linux

PictureBox Control
Displays graphics in bitmap, GIF, JPEG, metafile, or icon format.

PrintDialog Component
Selects a printer, chooses the pages to print, and determines other print-related settings.

PrintDocument Component
Sets the properties that describe what to print, and prints the document in Windows-based applications.

PrintPreviewControl Control
Allows you to create your own PrintPreview component or dialog box instead of using the pre-configured version.

PrintPreviewDialog Control
Displays a document as it will appear when it is printed.

ProgressBar Control
Graphically indicates the progress of an action towards completion.

RadioButton Control
Presents a set of two or more mutually exclusive options to the user.

RichTextBox Control
Allows users to enter, display, and manipulate text with formatting.

SaveFileDialog Component
Selects files to save and where to save them.

SoundPlayer Class Enables you to easily include sounds in your applications.

SplitContainer Control
Allows the user to resize a docked control.

Splitter Control
Allows the user to resize a docked control (.NET Framework version 1.x).

StatusBar Control
Displays status information related to the control that has focus. Although StatusStrip replaces and extends the StatusBar control of previous versions, StatusBar is retained for both backward compatibility and future use if you choose.

StatusStrip Control
Represents a Windows status bar control. Although StatusStrip replaces and extends the StatusBar control of previous versions, StatusBar is retained for both backward compatibility and future use if you choose.

TabControl Control
Displays multiple tabs that can contain pictures or other controls.

TableLayoutPanel Control
Represents a panel that dynamically lays out its contents in a grid composed of rows and columns.

TextBox Control
Allows editable, multiline input from the user.

Timer Component
Raises an event at regular intervals.

ToolBar Control
Displays menus and bitmapped buttons that activate commands. You can extend the functionality of the control and modify its appearance and behavior. Although ToolStrip replaces and adds functionality to the ToolBar control of previous versions, ToolBar is retained for both backward compatibility and future use if you choose.

ToolStrip Control
Creates custom toolbars and menus in your Windows Forms applications. Although ToolStrip replaces and adds functionality to the ToolBar control of previous versions, ToolBar is retained for both backward compatibility and future use if you choose.

ToolStripContainer Control
Provides panels on each side of a form for docking, rafting, and arranging ToolStrip controls, and a central ToolStripContentPanel for traditional controls.

ToolStripPanel Control
Provides one panel for docking, rafting and arranging ToolStrip controls.

ToolStripProgressBar Control Overview
Graphically indicates the progress of an action towards completion. The ToolStripProgressBar is typically contained in a StatusStrip.

ToolTip Component
Displays text when the user points at other controls.

TrackBar Control
Allows navigation through a large amount of information or visually adjusting a numeric setting.

TreeView Control
Displays a hierarchy of nodes that can be expanded or collapsed.

WebBrowser Control
Hosts Web pages and provides Internet Web browsing capabilities to your application.

Windows Forms Controls Used to List Options
Describes a set of controls used to provide users with a list of options to choose from.

Windows Forms Controls
Explains the use of Windows Forms controls, and describes important concepts for working with them.

Developing Windows Forms Controls at Design Time
Provides links to step-by-step topics, recommendations for which kind of control to create, and other information about creating your own control.

Controls and Programmable Objects Compared in Various Languages and Libraries
Provides a table that maps controls in Visual Basic 6.0 to the corresponding control in Visual Basic .NET. Note that controls are now classes in the .NET Framework.

How to: Add ActiveX Controls to Windows Forms
Describes how to use ActiveX controls on Windows Forms.

Оцените статью