This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
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.
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).
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.
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:
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.
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.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?