Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Overview of using controls

Feedback

In this article

Windows Forms controls are reusable components that encapsulate user interface functionality and are used in client-side, Windows-based applications. Not only does Windows Forms provide many ready-to-use controls, it also provides the infrastructure for developing your own controls. You can combine existing controls, extend existing controls, or author your own custom controls. For more information, seeCreate new controls overview.

Adding controls

Controls are added through the Visual Studio Designer. With the Designer, you can place, size, align, and move controls. Alternatively, controls can be added through code. For more information, seeAdd a control (Windows Forms).

Layout options

The position a control appears on a parent is determined by the value of theLocation property relative to the top-left of the parent surface. The top-left position coordinate in the parent is(x0,y0). The size of the control is determined by theSize property and represents the width and height of the control.

Besides manual positioning and sizing, various container controls are available that help with automatic placement of controls.

For more information, seePosition and layout of controls andHow to dock and anchor controls.

Control events

Controls have more than 60 events through the base classControl. These include thePaint event, which causes a control to be drawn, events related to displaying a window, such as theResize andLayout events, and low-level mouse and keyboard events. Some low-level events are synthesized byControl into semantic events such asClick andDoubleClick. Most shared events fall under these categories:

  • Mouse events
  • Keyboard events
  • Property changed events
  • Other events

Not every control responds to every event. For example, theLabel control doesn't respond to keyboard input, and theControl.PreviewKeyDown event isn't raised.

Often, a control is a wrapper for an underlying Win32 control, and using thePaint event to draw on top of the control might be limited or do nothing at all, since the control is ultimately drawn by Windows.

For more information, seeControl events andHow to handle a control event.

Control accessibility

Windows Forms has accessibility support for screen readers and voice input utilities for verbal commands. However, you must design your UI with accessibility in mind. Windows Forms controls expose various properties to handle accessibility. For more information about these properties, seeProviding Accessibility Information for Controls.

See also

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?