Setting Properties for Controls, Documents, and Forms
Properties define the state, behavior, and appearance of a form, document, or control. Most graphical controls contain properties that can be changed to define their visual appearance. Controls, documents, and forms can also expose properties that specify how they will interact with the user and the information that they need to operate at run time.
Use the Properties window to view and set the design-time properties for a form, document, or control. You can also use the Properties window to edit and view file, project, and solution properties. Other properties might be available only at run time and can be accessed by code.
To set properties using the Properties window
- If the Properties window is not visible, choose Properties Window from the View menu or press F4.
- If the item that you want to modify is not selected, use the Object drop-down list to select it.
- In the Properties window, select the property that you want to modify.
For example, select forecolor to change the color of the text on the control.
- Specify a value for the property.
Depending on the property, you might be required to type a text or numerical value, select a value from a list of property values, or set the value in a custom editor. For information on the proper value type for the property, see the documentation for the property you are modifying.
Setting Properties that Return (Structures &) Objects
A property might return an object, which might, in turn, have properties. For example, WinForm has a Location property that returns a Point structure. The structure has X and Y members that specify the default screen location of the form.
To set a property that returns an object
- Select the item that you want to modify.
- In the Properties window, expand the node of the property that you want to modify.
- In the group of indented properties belonging to the structure or object, select the property you want to modify, and specify a value.
Setting a Single Property for Multiple Controls
You can specify the same property value for a group of controls. This technique can be useful, for example, if you add several button controls to a form or document and want each button to have the same value for the height and width properties.
Note If you select multiple controls of different types, the Properties window displays only the properties that are common to all the selected controls.
To set the value of a property for multiple controls
- Select the first control in the group of controls that you want to modify.
- Hold down the CTRL key while selecting the other controls that you want to modify.
- In the Properties window, set the value for the property.
The value is then set for the property for each control that you selected.
Viewing Properties by Category
Some controls, documents, and forms display a large number of properties in the Properties window. This can make it difficult to locate the property you want to set. The Properties window allows you to view the properties for a form or control in a categorized view instead of an alphabetic view.
To view properties by category
- In the Properties window, click the Categorized button .
- The properties for the selected form or control will be separated into categories defined by the control.
- Expanding the node next to the category name hides the properties in the category. To return to the default alphabetic view, click the Sort Properties Alphabetically button in the Properties window.
Setting Complex Properties
Some controls, documents, and forms require complex property settings, or settings not easily expressed in the Properties window itself, for example, HTML tables. These controls provide a custom dialog box called a Property Pages dialog box to specify these complex property settings.
To access the property page for a control
- Select the control whose property page you want to access.
- In the Properties window, click the Property Pages button .
The Property Pages dialog box for the control is displayed.
Note If this button is unavailable, the selected control does not have a property page.