Aracılığıyla paylaş


User Control Designer

Makes it possible for you to visually create your own Windows Forms control by combining existing controls. A Windows Forms user control is a class that derives from the UserControl class.

Note

There are also user-authored server controls that are developed as ASP.NET pages and saved as a text file with an .ascx extension. The ASP.NET page framework compiles a user control on the fly to a class that derives from System.Web.UI.UserControl.

Using the designer, you can:

  • Add components, data items, and Window Forms controls from the Toolbox or from Server Explorer.

  • Group together a set of controls into a single control.

  • Double-click the designer and write code in the general declarations section of the class, or double-click an element contained on the class to write code for that element.

To open the designer, create a Windows Control Library project. The new project opens with the User Control Designer visible.

The User Control Designer acts as a design surface for user controls, allowing you to use much the same model you do for forms. For example, when you add a button to a form, you see an icon representing that element. You can click on it to access its properties, or you can press F7 to move to the Code Editor. The same is true for the User Control Designer: You can add and configure visual and nonvisual elements through interaction with the design surface, and program these elements and their events.

When you add a visual element to your user control, it is placed on the design surface, allowing you to adjust the visual representation and position of that element.

When you add a nonvisual item (such as a DirectorySearcher component) to your user control, the item appears in the Component Tray at the bottom of the designer.

Note

The tray is an instance of the Component Designer. This acts as a collection point for nonvisual items, allowing you to work with them without interfering with the arrangement of controls on the page or form.

See Also

Tasks

How to: Author Composite Controls

Walkthrough: Authoring a Composite Control with Visual Basic

Walkthrough: Authoring a Composite Control with Visual C#

Concepts

Varieties of Custom Controls