Alex Rivera | Logout

Delphi 2010 - property wizard or something similar, to avoid manual coding getters / setters

Asked 2011-05-21T10:03:20.027
12

Is there any built in or external tool (wizard) to easily add class member (published field) with getters / setters?

adding each field requires me to write quite lot of code. Let's assume I need to add Foo: Bar; property.

I'll need to write

FFoo: TBar;
procedure SetFoo(const AValue: TBar);
function GetFoo: TBar;

...

property Foo: TBar read GetFoo write SetFoo

any tool to make it quick and easy?

Edit
Report

1 Answer

6

Just write the property declarataion:

property Foo: TBar read GetFoo write SetFoo;

then with your cursor on the property (or anywhere within the class declaration), press Ctrl-Shft-C and the IDE will autocomplete the declarations for you, including the implementation stubbs.

Please note that you may have to make sure that the "Finish incomplete properties" option is checked. You can find that under Tools | Options | Environment Options | Explorer.

answered 2011-05-21T10:07:48.040

Your Answer