Editing the Property as a Whole

From RAD Studio
Jump to: navigation, search

Go Up to Adding Property Editors


You can optionally provide a dialog box in which the user can visually edit a property. The most common use of property editors is for properties that are themselves classes. An example is the Font property, for which the user can open a font dialog box to choose all the attributes of the font at once.

To provide a whole-property editor dialog box, override the property-editor class's Edit method.

Edit methods use the same Get and Set methods used in writing GetValue and SetValue methods. In fact, an Edit method calls both a Get method and a Set method. Because the editor is type-specific, there is usually no need to convert the property values to strings. The editor generally deals with the value "as retrieved."

When the user clicks the '...' button next to the property or double-clicks the value column, the Object Inspector calls the property editor's Edit method.

Within your implementation of the Edit method, follow these steps:

  1. Construct the editor you are using for the property.
  2. Read the current value and assign it to the property using a Get method.
  3. When the user selects a new value, assign that value to the property using a Set method.
  4. Destroy the editor.

See Also