如何将属性添加到将反映在对象检查器上的组件

non*_*one 4 ide delphi delphi-7

在Delphi 7中,当向对象添加属性时,如何在对象检查器中看到该属性?

And*_*and 14

制作物业published.例如,

private
  FMyProperty: integer;
published
  property MyProperty: integer read FMyProperty write FMyProperty;
Run Code Online (Sandbox Code Playgroud)

通常,您需要在更改属性时重新绘制控件(或执行其他一些处理).那你可以做

private
  FMyProperty: integer;
  procedure SetMyProperty(MyProperty: integer);
published
  property MyProperty: integer read FMyProperty write SetMyProperty;

...

procedure TMyControl.SetMyProperty(MyProperty: integer);
begin
  if FMyProperty <> MyProperty then
  begin
    FMyProperty := MyProperty;
    Invalidate; // for example
  end;
end;
Run Code Online (Sandbox Code Playgroud)

  • `重绘'看起来有点沉重.你是不是打算叫'Invalidate`并等待下一个油漆循环以自然的方式出现. (3认同)