Show: Delphi C++
Display Preferences

Using Class Completion

From RAD Studio XE2
Jump to: navigation, search

Go Up to How To Edit Code in the Code Editor

Class completion automates the definition of new classes by generating skeleton code for Delphi class members that you declare.

To use class completion

  1. In the Code Editor, declare a class in the interface section of a unit. For example, you might enter the following:
type TMyButton = class(TButton)
    property Size: Integer;
    procedure DoSomething;
end;
  1. Right-click the class declaration and choose Complete Class at Cursor.
    Tip: You can also invoke Class Completion by placing the cursor within the class declaration and pressing CTRL+SHIFT+C.

Class Completion automatically adds the read and write specifiers to the declarations for any properties that require them, and then adds skeleton code in the implementation section for each class method.

Tip: You can also use class completion to fill in interface declarations for methods that you define in the implementation section.

After invoking class completion, the previous sample code appears as follows:

type TMyButton = class(TButton)
  private
    FSize: Integer;
      procedure SetSize(const Value: Integer);
  published
      property Size: Integer read FSize write set_Size;
      procedure DoSomething;
end;

The following skeleton code is added to the implementation section:

{ TMyButton }

procedure TMyButton.DoSomething;
begin

end;

procedure TMyButton.SetSize(const Value: Integer);
begin
  FSize := Value;
end;

If your declarations and implementations are sorted alphabetically, class completion maintains their sorted order. Otherwise, new routines are placed at the end of the implementation section of the unit and new declarations are placed in private sections at the beginning of the class declaration.

Tip: The Finish Incomplete Properties option on the Tools > Options > Explorer page determines whether class completion completes property declarations.
Personal tools
Previous Versions
In other languages