SETTING PROPERTIES

When you select a control, the Properties window allows you to view and edit the control’s properties. For most properties, you can simply click the property and type a new value for the control. Some properties are more complex than others and provide drop-down lists or special dialog boxes to set the property’s value. Most of the editors provided for setting property values are fairly self-explanatory, so they are not described in detail here.


NOTE
You can press Ctrl+Z and Ctrl+Y to undo and redo changes in the Windows Form Designer, respectively, so you should feel free to experiment. You can change property values and add or remove controls and restore the form if you don’t like the changes.

In addition to using the Properties window to set a single control’s properties one at a time, you can quickly set property values for groups of controls in a couple of ways. The following sections describe some of the most useful of these techniques.

Setting Group Properties

If you select a group of controls, you can sometimes use the Properties window to give all of the controls the same property value all at once. For example, suppose you select a group of TextBoxes. Then you can use the Properties window to simultaneously give them the same values for their Anchor, Text, MultiLine, Font, and other properties.

Sometimes, this even works when you select different kinds of controls at the same time. For example, if you select some TextBoxes and some Labels, you can set all of the controls’ Text properties at the same time. You cannot set the TextBoxes’ MultiLine properties, however, because the Labels do not have a MultiLine property.


BLANKING TEXT
One handy use for this technique is to set the Text property to a blank string for a group of TextBox controls. Unfortunately, if the selected TextBoxes have different Text values, the Properties window displays a blank value for the Text property. If you then try to make the property blank, the Properties window doesn’t think you’ve changed the value, so it doesn’t blank the controls’ Text properties.
To work around this restriction, first set the Text property to any non-blank value (“x” will do) to give all of the controls the same value. Then delete the Text value to blank all of the controls.

Using Smart Tags

Many controls display a smart tag when you select them on the designer. The smart tag looks like a little box containing a right-pointing triangle. When you click the smart tag, a small dialog box appears to let you perform common tasks for the control quickly and easily.

Figure 3-4 shows a PictureBox with the smart tag expanded. Because the smart tag’s dialog box is visible, the smart tag indicator shows a left-pointing triangle. If you click this, the dialog box disappears.

FIGURE 3-4: The PictureBox control’s smart tag lets you set common control properties.

image

The PictureBox control’s smart tag dialog box lets you choose an image for the control, set the control’s SizeMode, or dock the control in its container. These actions set the control’s Image, SizeMode, and Dock properties.

Many controls, particularly the more complicated kinds, provide smart tags to let you perform common actions without using the Properties window.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.51.103