Windows form control library

Руководство. Создание элементов управления для Windows Forms How to: Author controls for Windows Forms

Элемент управления выполняет роль визуальной связи между пользователем и программой. A control represents a graphical link between the user and the program. Он может предоставлять или обрабатывать данные, принимать входные данные пользователя, реагировать на события или выполнять любые другие функции, устанавливающие связь между пользователем и приложением. A control can provide or process data, accept user input, respond to events, or perform any number of other functions that connect the user and the application. Поскольку элемент управления — это по сути компонент с графическим интерфейсом, он может выполнять любую функцию компонента и в то же время обеспечивать взаимодействие с пользователем. Because a control is essentially a component with a graphical interface, it can serve any function that a component does, as well as provide user interaction. Элементы управления создаются для конкретных целей, и процесс их создания входит в процесс программирования. Controls are created to serve specific purposes, and authoring controls is just another programming task. Ниже описан процесс создания элемента управления с учетом всего вышесказанного. With that in mind, the following steps represent an overview of the control authoring process. Ссылки указывают на дополнительные сведения об отдельных этапах. Links provide additional information on the individual steps.

Создание элемента управления To author a control

Определите, какую функцию или роль ваш элемент управления должен выполнять в приложении. Determine what you want your control to accomplish, or what part it will play in your application. При этом необходимо учитывать следующие факторы. Factors to consider are:

Какого рода графический интерфейс вам требуется? What kind of graphical interface do you need?

Какие взаимодействия с пользователем будет обрабатывать этот элемент управления? What specific user interactions will this control handle?

Обладают ли необходимыми функциональными возможностями какие-либо из существующих элементов управления? Is the functionality you need provided by any existing controls?

Можно ли получить необходимую функциональную возможность, объединив несколько элементов управления Windows Forms? Can you get the functionality you need by combining several Windows Forms controls?

Если для элемента управления требуется объектная модель, определите, каким образом функциональные возможности будут распределяться по объектной модели, и разделите их между элементом управления и подчиненными объектами. If you need an object model for your control, determine how functionality will be distributed throughout the object model, and divide up functionality between the control and any subobjects. Объектная модель может пригодиться при планировании сложного элемента управления, а также в случае, если вам требуется внедрить сразу несколько функциональных возможностей. An object model may be useful if you are planning a complex control, or want to incorporate several functionalities.

Определите необходимый тип элемента управления (например, пользовательский элемент управления, настраиваемый элемент управления, наследуемый элемент управления Windows Forms). Determine the type of control (for example, user control, custom control, inherited Windows Forms control) you need. Дополнительные сведения см. в разделах Рекомендации относительно типов элементов управления и Разновидности пользовательских элементов управления. For details, see Control Type Recommendations and Varieties of Custom Controls.

Представьте функции в качестве свойств, методов и событий элемента управления и его подчиненных объектов или вспомогательных структур и назначьте соответствующие уровни доступа (например, public, protected и т. д.). Express functionality as properties, methods, and events of the control and its subobjects or subsidiary structures, and assign appropriate access levels (for example, public, protected, and so on).

Читайте также:  Как отключить защиту windows 10 20h2

Если для элемента управления необходима пользовательская отрисовка, добавьте соответствующий код. If you need custom painting for your control, add code for it. Дополнительные сведения см. в разделе Рисование и отрисовка пользовательского элемента управления. For details, see Custom Control Painting and Rendering.

Если элемент управления наследуется от UserControl , можно проверить его поведение во время выполнения, создав проект элемента управления и запустив его в тестовом контейнере UserControl. If your control inherits from UserControl, you can test its runtime behavior by building the control project and running it in the UserControl Test Container. Дополнительные сведения см. в разделе как проверить поведение Run-Time UserControl. For more information, see How to: Test the Run-Time Behavior of a UserControl.

Кроме того, для тестирования и отладки элемента управления можно создать новый проект, например приложение Windows, и поместив его в контейнер. You can also test and debug your control by creating a new project, such as a Windows Application, and placing it into a container. Этот процесс демонстрируется как часть пошагового руководства. Создание составного элемента управления. This process is demonstrated as part of Walkthrough: Authoring a Composite Control.

При добавлении каждой функции добавляйте ее в тестовый проект для реализации новых функциональных возможностей. As you add each feature, add features to your test project to exercise the new functionality.

Повторите эти действия, добавив необходимые уточнения. Repeat, refining the design.

Упакуйте и разверните элемент управления. Package and deploy your control. Дополнительные сведения см. в разделе первое знакомство с развертыванием в Visual Studio. For details, see First look at deployment in Visual Studio.

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.

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.

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.

Читайте также:  Windows search file servers

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.

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