Update a default value only during design-time

后端 未结 1 1978
有刺的猬
有刺的猬 2021-01-29 08:37

I would like to update the default value of a private variable linked to a public property only during design-time, in case it\'s possible.

TMyComp = class(TComp         


        
相关标签:
1条回答
  • 2021-01-29 09:13
    procedure TMyComponent.SetColumnWidth(const Value: Integer);
    begin
    if FColumnWidth <> Value then
      begin
        FColumnWidth:= Value;
        if csDesigning in ComponentState then
          FColumnWidthDef:= FColumnWidth;  
      end;
    end;
    

    but this do not go to dfm file and when you run app your def will be gone why not to put this as another published property? or better write "stored" function like it is done many times in delphi source code like this

    property BorderIcons: TBorderIcons read FBorderIcons write SetBorderIcons stored IsForm
          default [biSystemMenu, biMinimize, biMaximize];
    
    0 讨论(0)
提交回复
热议问题