【问题标题】:published property not shown in Object Inspector对象检查器中未显示已发布的属性
【发布时间】:2014-07-16 21:15:15
【问题描述】:

我的环境:Windows 7 Pro(32 位)上的 RadStudio XE4。

Difference between property and function or procedures

在上面的Q和A中,有一个回复说 “更具体地说,如果您使用 Delphi IDE 进行编程,您将看到已发布的属性 (-y+ies) 将显示在 Object Inspector 中”。

我试过了。

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
  private
    FSampleProp1: Integer;
    function GetSampleProp1(): Integer;
    procedure SetSampleProp1(val: Integer);
    { Private declaration }
  published
    { Private declaration }
    property SampleProp1: Integer read GetSampleProp1 write SetSampleProp1;
  end;

我希望在 Object Inspector 的“属性”选项卡中有“SampleProp1”。但我没有那个。

相反,我在 [Delphi Class Exploroer] 窗口中有“SampleProp1”。

我在对象检查器中拥有已发布的属性是不正确的吗?

【问题讨论】:

标签: delphi


【解决方案1】:

对象检查器仅显示在设计时包中向 IDE 注册的属性。你还没有这样做。

因此,您可以将表单包含在设计时包中,并通过调用 RegisterCustomModule 进行注册。但是,如果您的表单正在您的应用程序中积极开发,这可能会非常不方便。您可能会发现自己在设计时包和应用程序之间反复失去同步。

另一种应用表单范围行为更改的方法是创建一个非可视组件,您可以将其放到表单中。这种方法的优点是您可以将表单更改为您想要的内容,并且不会与您的设计时组件不同步。

【讨论】:

  • @Heffernan:不,我现在不需要进一步的帮助。谢谢你的提问。
猜你喜欢
  • 1970-01-01
  • 2015-03-06
  • 2020-09-04
  • 2016-09-17
  • 1970-01-01
  • 2016-12-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多