delphidfm

Does the order of properties in DFM file matter?


Could a not-standard order of the properties cause any problem?

For example, the IDE stores a TButton component in the DFM file as follows:

  object Button1: TButton
    Left = 288
    Top = 160
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end

If I manually change the order of the properties, could this cause any problem?

  object Button1: TButton     
    OnClick = Button1Click
    Left = 288
    Top = 160
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
  end

Solution

  • There seem to be cases where the order actually matters!

    For examples see the comments in the published section of TStandardColorMap, TActionManager, TActionClientItem, TTabControl, TTreeView, TMonthCalendar, TDateTimePicker and TComboBoxEx (to just name a few from Vcl), where the order of published properties is relevant.

    As the order of properties in the DFM determines the order the published properties are set, any other order may affect the values of the properties after reading a component from the DFM.

    The fix-up mechanism mentioned by MartynA in another answer is not used for these sort of properties.