我需要创建和管理许多简单的已发布属性。如果它们看起来像这样,我称它们为自动属性:
private
FTitle: string;
published
property Title: string read FTitle write FTitle;
通常我用下面的方式创建它们:
-
添加属性名称和类型:
property Title: string
选择并复制属性名称Title
到剪贴板。
Appending the line with read F
Ctrl+V write F
Ctrl+V ;
- Pressing Ctrl+Shift+C and this will generate the private field
有没有办法排除步骤 2 和 3 以更快地添加属性?也许可以为此创建一些宏?
从 Delphi 2006 开始,您可以使用 LiveTemplates。
以Delphi XE为例:
- type propf and hit Ctrl + J keystroke
- write the property name and hit TAB key
- write the property type name, hit TAB or ENTER key and you are done
您可以在此处找到有关如何编写自己的实时模板的更多信息:
- Delphi Live Templates - http://delphi.wikia.com
- Creating Live Templates - http://docwiki.embarcadero.com
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)