共用方式為


Controls in Dialog Boxes

 

The latest version of this topic can be found at Controls in Dialog Boxes.

You can add controls to a dialog box using the Dialog Editor tab in the Toolbox window, which enables you to choose the control you want and drag it onto the dialog box. By default, the Toolbox window is set to auto hide. It appears as a tab on the left margin of your solution when the Dialog editor is open. However, you can pin the Toolbox window into position by clicking the Auto Hide button in the upper right corner of the window. For more information on how to control the behavior of this window, see Window Management.

The fastest way to add controls to a dialog box, reposition existing controls, or move controls from one dialog box to another, is to use the drag-and-drop method. The control's position is outlined in a dotted line until it is dropped into the dialog box. When you add a control to a dialog box with the drag-and-drop method, the control is given a standard height appropriate to that type of control.

When you add a control to a dialog box or reposition it, its final placement may be determined by guides or margins, or whether you have the layout grid turned on.

Once you have added a control to the dialog box, you can change properties such as its caption in the Properties Window. You can select multiple controls and change their properties all at once.

For information on adding resources to managed projects, please see Resources in Applications in the .NET Framework Developer's Guide. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resources strings to properties, see Walkthrough: Localizing Windows Forms and Walkthrough: Using Resources for Localization with ASP.NET.

Requirements

Win32

See Also

Adding Event Handlers for Dialog Box Controls
Dialog Box Controls and Variable Types
Dialog Editor