加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 09:44:19 所属栏目:大数据 来源:网络整理
导读:在Delphi 7中,当向对象添加属性时,如何在对象检查器中看到该属性? 解决方法 发布该属性.例如, private FMyProperty: integer;published property MyProperty: integer read FMyProperty write FMyProperty; 通常,您需要在更改属性时重新绘制控件(或执行其他
在Delphi 7中,当向对象添加属性时,如何在对象检查器中看到该属性?

解决方法

发布该属性.例如,

private
  FMyProperty: integer;
published
  property MyProperty: integer read FMyProperty write FMyProperty;

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

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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读