Partager via


Manipulating Objects

There are several ways you can manipulate and work with objects on a form at design time:

  • Set the size and position of objects in the Form Designer by expanding, shrinking, or dragging them.
  • Align controls by choosing options on the Format menu or using the alignment tools on the Layout toolbar. For more information about the Layout toolbar, see Aligning Controls in Forms.
  • Set colors using the Palette toolbar. For more information about using the Palette toolbar, see Customizing Forms.
  • View object property settings, display inherited code for objects, events, and methods, set values for properties, and restrict your view to only modified properties using the Properties window.

Properties Window

The primary point of control for all objects in your form is the Properties window. The Properties window displays the properties, events, and methods and their settings for a selected form, data environment, cursor, relation, or control.

Properties window

For more information about the Properties window, see Properties Window.

Viewing Properties for Objects

To view properties for an object, open the Properties window.

To open the Properties window

  • On the Window menu, click Properties Window.

You can also open the Properties window by right-clicking the Form Designer or Data Environment Designer and choosing Properties from the shortcut menu.

To view properties for an object

  • Click the form or an object on the form.

The Properties window displays the properties, methods, and events for the selected object. You can also select the object from the object list in the Properties window.

To view properties that multiple objects have in common, press and hold SHIFT while you select several objects on the form. The properties list shows common properties for the objects you select.

To view settings for properties, events, and methods that appear truncated in the properties list, expand the Properties window or display the value tip by moving the mouse over the property, event, or method in the properties list. Value tips show the visual class libraries, if they exist, from which methods and events are inherited and settings for read-only properties.

Displaying Inherited Code for Objects, Events, and Methods

You can view code inherited from parent classes for objects, events, and methods, making it easier to decide whether you want to use or override the inherited code.

Note   The View Parent and View Inherited Code features support only the viewing of parent code, not editing. To edit parent class code if using a subclass, use the Class Browser. For more information, see Viewing Class Definition Code and Managing Classes with the Class Browser.

You can choose to view inherited or parent code from inside the code window or the properties list in the Properties window.

To view inherited code using the code window

  1. Choose an object from the form.

    -or-

    Choose an event or method from the properties list in the Properties window.

  2. To open the code window, double-click the object, event, or method.

  3. In the code window, click the View Parent Code button to display the list of all parent classes.

  4. Select the parent class.

An editing window opens and displays the parent code. You can also choose the View Parent Code button in the code window by pressing ALT+I.

Note   The View Parent Code button is available in the code window only when there is at least one parent class that contains code. When source code exists, parent classes appear in bold.

Visual FoxPro displays only those parent classes for the selected control. If a list of parent classes is available, the parent classes appear in order from the most immediate or top parent class to the one closest to the base class, traversing the parent tree. The base class does not appear.

If code inherited from the immediate parent class exists, and the parent class is a member of a container class, Visual FoxPro displays the container class followed by a separator and then the classes in the parent tree. Other classes that traverse the container hierarchy might contain code but are not displayed in the list.

Viewing inherited code using the properties list in the Properties window traverses the parent or container tree to reach the inherited parent class.

Viewing Inherited Code using the Properties Window

If inherited code exists for a method or event, the parent class name and class libraries from which the method or event inherits code appear in the properties list of the Properties window as follows:

Inherited cClassname ClassLibrary

To view inherited code using the properties list

  1. Select an object on the form.
  2. In properties list in the Properties window, right-click the event or method.
  3. From the shortcut menu, select View Inherited Code.

An editing window opens and displays the inherited parent code.

Setting Properties for Objects

You can set or change properties at design time or programmatically.

Note   Some properties are evaluated at design time, so any memory variables or arrays used in expressions for these properties must be in scope at design time. Properties that are read-only at design time, such as the Class property of an object, are displayed in italics in the properties list of the Properties window.

To set or edit the value for a property

  1. Click an object on the form.
  2. From the properties list in the Properties window, select a property.
  3. In the property settings box, type or choose the desired setting for the selected property.

You can also select an object from the object box in the Properties window.

If the property requires a character value, you do not have to include the value in quotation marks. For example, if you want the caption of a form to display as Customer, type Customer in the property settings box. However, if you want the caption to display as "Customer" with quotation marks (""), type "Customer" in the property settings box.

Setting Properties to Expressions

You can set certain properties to the results of expressions or functions in the Properties window. Visual FoxPro evaluates the expression for a property when you enter it in the Properties window and when the object is initialized at design or run time. Once the object is created, the property setting does not change until you or the user explicitly changes it.

Caution   If you set a property to the result of a user-defined function, Visual FoxPro evaluates the function when you set the property, or when you modify or run the form. If an error exists in the user-defined function, you might not be able to open your form.

You can also set the property to the user-defined function in the Init event of the object as in the following example:

THIS.Caption = myfunction( )

However, if an error exists in the user-defined function, you will still be unable to run the form, but you can modify it.

To set a property to an expression

  1. From the properties list, select the property for which you want to enter an expression.
  2. In the property settings box, type an equal sign (=) followed by the expression.

For example, you can indicate the currently active table when the form runs by selecting the Caption property of the form and typing =ALIAS( ) in the property settings box.

You can also specify expressions for properties by using the Expression Builder. To open the Expression Builder, select the desired property and click the Function button in the Properties window.

Showing Properties with Modified Settings

In the Properties window, you can choose to list only those properties for which the default settings have been changed.

To view properties with modified settings

  1. Right-click the Properties window outside the properties list.
  2. From the shortcut menu, select Non-Default Properties Only.

The properties list shows only those properties, events, and methods whose settings have been changed.

See Also

Adding Properties and Methods to a Form | Defining Form Behavior | Creating Forms | Editing Event and Method Code | Form Designer