How to create an auto-property faster in Delphi IDE?

前端 未结 3 1976
情歌与酒
情歌与酒 2021-01-11 14:56

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

private
  FTitle: string;
published
  prope         


        
3条回答
  •  悲&欢浪女
    2021-01-11 15:44

    I use macros for that purpose.

    For example I have model with fields

    private
      FTitle: string;
      FName: string
      FAge: Integer
    

    then I copy-paste the fields into published section and create macro

    1. Goto first field and hit Home
    2. Hit Ctrl + Shift + R to start recording macro
    3. Use Crtl + ->, Crtl + <- and End keys for navigation and convert first field to property like property Title: string Read FTitle Write FTitle;
    4. After that hit Home and go to next row
    5. Finish macro by hitting Ctrl + Shift + R
    6. For all other fields, just press Crtl + Shift + P

    At first it seems difficult, but the skills will pay off.

提交回复
热议问题