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

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

问题描述

我需要创建和管理许多简单的已发布属性。我称之为自动属性,如果它们是这样的:

  private 
FTitle:string;
发布
属性标题:string read FTitle write FTitle;

通常我会创建他们的方式:


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



    属性标题:string / p>


  2. 选择并复制属性名称标题到剪贴板。


  3. 使用追加行读取F Ctrl + V 写入F Ctrl + V ;


  4. Ctrl + Shift + C ,这将生成私有字段

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

解决方案

自从Delphi 2006以来,您可以使用LiveTemplates。



在Delphi XE中,例如:




  • type propf 并点击 Ctrl + J 击键

  • 写入属性名称,并点击 TAB

  • 写入属性类型名称,点击 TAB 或< kbd> ENTER 键,你完成了



您可以在这里找到更多关于如何编写自己的Live Templates的信息:




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. Adding property name and type:

    property Title: string

  2. Selecting and copying property name Title to clipboard.

  3. Appending the line with read F Ctrl+V write F Ctrl+V ;

  4. Pressing Ctrl+Shift+C and this will generate the private field

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

解决方案

Since Delphi 2006 you can use LiveTemplates.

In Delphi XE for example:

  • 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天全站免登陆