70-526 MCTSConfigure controls on a Windows Form at design time to optimize the UIOnce you have placed a control on a Form or Container, you will more often than not want to change its location and/or size. These properties of a control can be modifed within the Forms Designer as well as through the use of the Properties Window. Modifying either of these properties graphically instantly allows you to see how the control looks on a Form or within a Container. Adjusting the size of a controlTo adjust the size of a control with the mouse, you first need to select it by clicking on it. This causes the control to display eight sizing handles. Dragging any of these sizing handles changes the size of the control. ![]() The ARROW keys can also be used to resize a control in two different ways, altering the position of the right or bottom edge of the control. ![]() Alternatively you can resize a control using the Size property located in the Properties Window. This property has two components that can be modified, Height and Width. Resizing multiple controls on a formMore than one control can be resized at a time, to do this either lasso the controls with the mouse, or select them one by one whilst holding down the CTRL or SHIFT key. Dragging any of the eight sizing handles on any selected control will change the size of all of the selected controls. Alternatively, on the Format menu, choose Make Same Size, and select one of the four options. The first three commands change the dimensions of the controls to match the first-selected control. Adjusting the location of a controlTo adjust the location of a control with the mouse, you first need to select it by clicking on it and
hold down the left mouse key. This causes the size all icon The ARROW keys can also be used to adjust the location of a control in two different ways Alternatively you can resize a control using the Location property located in the Properties Window. This property has two components that can be modified, X and Y. Adjusting the location of multiple controlsMore than one control can be moved at a time, to do this either lasso the controls with the mouse, or select them one by one whilst holding down the CTRL or SHIFT key. Move the controls with either the mouse or the ARROW keys. SnapLinesThe default setting for the designer window is to use SnapLines. These are a new feature of Visual Studio. SnapLines are horizontal and vertical line segments dynamically created in the user interface to help the programmer design the layout of the controls within containers. They appear when you are moving a selected control or set of controls near a position that would align with another control or set of controls. The selected control(s) will "snap" to the suggested position as you move it past the other controls. ![]() SnapLines are generated dynamically and automatically as a control edge moves near another control or near the boundaries of its container. This can occur when a control is added from the toolbox, or moved/resized by the mouse or keyboard. Controls typically have both horizontal and vertical snaplines. SnapLines can be manipulated by the programmer by setting a control’s Margin and Padding properties. The SnapLines's distance from a container’s border is the sum of the control's Margin property and the container’s Padding property. To enable SnapLines, do the following:
Using the GridWhen laying controls out on a Form, you have a choice of either laying them out using snap lines or by aligning the controls on a grid (as per visual studio 6). The default option when you install the IDE is to use snap lines, however if you wish to use the grid, then you need to set this up in the options. From the Tools menu, select Options. In the left pane of the dialog box, click Windows Forms Designer. This will cause the following dialog window to be displayed. ![]() There are four properties that control whether the grid is displayed and how it is used. To enable the grid, do the following:
When you now open any designer windows, the grid will now be enabled. ![]() Laying out controlsControls can be layed out using either the Format Menu or the Layout Toolbar. Locking controlsControls can be locked into position so that you do not accidentally move them within the form designer. A single control can be locked by setting the Locked property in the Properties Window. You can lock all of the controls currently on a form in one of two ways: To unlock the control(s), simply follow the same procedure. MSDN references
|