如何在 Delphi IDE 中更快地创建自动属性? [英] How to create an auto-property faster in Delphi IDE?

查看:21
本文介绍了如何在 Delphi IDE 中更快地创建自动属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建和管理许多简单的已发布属性.如果它们看起来像这样,我称它们为自动属性:

I need to create and manage many simple published properties. I call them auto-properties if they look like that:

private
  FTitle: string;
published
  property Title: string read FTitle write FTitle;

通常我会用下一个方法创建它们:

Usually I create them next way:

  1. 添加属性名称和类型:

  1. Adding property name and type:

属性标题:字符串

选择属性名称Title并将其复制到剪贴板.

Selecting and copying property name Title to clipboard.

添加行 read F Ctrl+V write F Ctrl+V ;

有没有办法排除步骤 2 和 3 以更快地添加属性?也许可以为此创建一些宏?

Is there any way to exclude steps 2 and 3 to add properties faster? Maybe it is possible to create some macro for this?

推荐答案

从 Delphi 2006 开始,您可以使用 LiveTemplates.

Since Delphi 2006 you can use LiveTemplates.

以 Delphi XE 为例:

In Delphi XE for example:

  • 输入 propf 并按 Ctrl +J 击键
  • 写下属性名并点击TAB
  • 写下属性类型名称,按TABENTER键即可完成
  • 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

您可以在此处找到有关如何编写自己的实时模板的更多信息:

You can find more information on how to write your own Live Templates here:

这篇关于如何在 Delphi IDE 中更快地创建自动属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆