Show: Object Pascal C++
Display Preferences

Setting Properties and Events

From Appmethod Topics
Jump to: navigation, search

Go Up to How To Create Forms and Projects, and Write the Code Behind

Properties, methods, and events are attributes of a component.

Changing code-related properties, such as the name of an event handler, in the Object Inspector automatically changes the corresponding source code. In addition, changes to the source code, such as renaming an event handler method in a form class declaration, is immediately reflected in the Object Inspector.

For information about the properties of each component, see the API documentation in the online Help.

Setting Properties at Design Time

At design time, The Object Inspector shows the published properties of the selected components on a form. When the property is editable, you can use the Object Inspector to edit it.

  1. On your form, click once on the object to select it.
  2. In the Object Inspector, click the Properties tab.
  3. Select the property that you want to change and either enter a value in the text box, select a value from the drop-down list, or click the ellipsis ProjectOptionsEllipsis.jpg next to the text box to use the associated property editor, depending on which update technique is available for the property. See Using Property Editors.
    Note: For properties of Boolean or enumerated types, you can choose values from a drop-down list or toggle their settings by double-clicking in Value column.

Editing Properties

  • Use the Tab key to toggle between the left-hand Property column and the right-hand Value column. When the cursor is in the Property column, you can navigate to any property by typing the first letters of its name.
  • If Plus Sign.png appears next to a property name, clicking Plus Sign.png or typing '+' on the Name column, when the property has focus, displays a list of subvalues for the property. Similarly, if a Minus Sign.png appears next to the property name, clicking Minus Sign.png or typing '-' on the Name column, hides the subvalues.

Note: By default, properties in the Legacy category are not shown. To change the display filters, right-click in the Object Inspector and choose View.

See Usage Tips for more information.

Setting Properties at Run Time

You can set writable properties at run time, by editing the source code.

For example, you can dynamically assign a caption to a form:

In Object Pascal:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form1.Caption := 'MyString';
end;

In C++:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Form1->Caption = "MyString";
}

Setting Events

  1. On your form, click once on the object to select it.
  2. On the Object Inspector, click the Events tab.
  3. If an event handler already exists, select it from the drop-down box. Otherwise, double-click the event to switch to Code view.
  4. Type the code you want to execute when the event occurs.

See Events page and Event Handlers for more information.

See Also

Personal tools
In other languages