【问题标题】:VCL Register Properties in Category not working类别中的 VCL 寄存器属性不起作用
【发布时间】:2019-12-01 04:59:29
【问题描述】:

我正在尝试对组件的一些属性进行分组。

type
  TcxGridButton = class(TcxButton)
  private
    FGridView : TcxGridDBTableView;
    FPopup : TPopupMenu;
    FImages : TcxImageList;
    FSortFilterEnabled : boolean;
    FCustomizeAndGroupEnabled : boolean;

    procedure AutoSize(Sender : TObject);
    procedure ClearFilter(Sender : TObject);
    procedure ExportToExcel(Sender : TObject);

    procedure SortFilter(Sender : TObject);
    procedure CustomizeAndGroup(Sender : TObject);

    procedure OnPopup(Sender : TObject);
  protected
    { Protected declarations }
  public
    { Public declarations }
    constructor Create(AOwner : TComponent); override;

    procedure Click; override;
  published
    property GridView : TcxGridDBTableView read FGridView write FGridView;
    property AllowSortFilter : boolean read FSortFilterEnabled write FSortFilterEnabled;
    property AllowCustomizeAndGroup : boolean read FCustomizeAndGroupEnabled write FCustomizeAndGroupEnabled;
  end;

我希望在 VCL 中名为 PopupMenu Settings 的组下显示 AllowSortFilter 和 AllowCustomizeAndGroup。

所以我这样做了:

procedure Register;
begin
  RegisterComponents('Roberts', [TcxGridButton]);

  RegisterPropertiesInCategory('PopupMenu Settings', TcxGridButton, ['AllowSortFilter','AllowCustomizeAndGroup']);
end;

不幸的是,这不起作用,我不知道为什么。语法似乎是正确的,没有错误。但是该组没有被创建。

问候 罗伯特

【问题讨论】:

  • 亲爱的上帝……您如何描述不使用其他词? :) 它没有注册类别下的两个属性...
  • 恕我直言,您写的是“不工作”,而不是“不注册”。 ide的什么行为让你认为属性没有被注册?
  • 属性已注册...但不在名为 Popupmenu Settings 的类别下... 此行无效,因此看起来:RegisterPropertiesInCategory('PopupMenu Settings', TcxGridButton, ['AllowSortFilter', 'AllowCustomizeAndGroup']);
  • 还有什么奇怪的我可以编译和安装组件,但是当我把组件放在表单上并尝试编译它时抱怨找不到 designintf...
  • “designintf not found”是因为您试图将设计时代码编译到您的应用程序中 - 您需要将代码注册到一个单独的单元中,而 不是 在你的应用程序的使用列表中。

标签: delphi components vcl


【解决方案1】:

我认为您可能在某个地方遗漏了一步,因为如果我组织您的 我认为应该组织的代码,然后我得到的结果是 AllowSortFilterAllowCustomizeAndGroup 条目正确显示 在 cxGridButton 的 PopUpMenuSettings 类别中。

这就是我所做的:

  • 将您的 TcxGridButton 代码,而不是您的 Register 程序放在一个新单元中, CategoryRTu(RT 运行时的缩写)。本单元使用 DesignIntf​​。

  • 将您的Register 过程放置在一个新单元CategoryDTu(DT 是DesignTime 的缩写)中。本单元确实使用 DesignIntf​​。

  • 创建了一个新包 Category.Dpk,其中 Contains CategoryDTu 和 Requires rtl、designide、vcl、dbrtl、vcldb、dxGDIPlusD7、dxCoreD7、cxLibraryD7、dxThemeD7、 cxPageControlD7、cxEditorsD7、cxDataD7、dxLayoutControlD7 和 cxGridD7。 D7 后缀是因为我在 Delphi7 中做了这个。其中一些可能不是绝对必要的,因为我通过将 TcxButton 添加到表单然后创建列表 将一些 Used 单位复制到 Requires 列表中。

  • 编译Category.Dpk并使用Component | Install packages安装Category.Bpl。

  • 创建了一个新项目并向其中添加了一个 TcxGrid 和一个 TcxGridButton。

  • 在对象检查器中选择 cxGridButton1,在 OI 中单击鼠标右键 并选择查看 |按类别

然后,展开 PopUpMenuSettings 节点,我看到 AllowSortFilterAllowCustomizeAndGroup.

【讨论】:

  • 非常感谢您提供的详细示例。正如所见,我是新手:)
猜你喜欢
  • 2015-11-15
  • 2019-12-13
  • 2013-08-25
  • 1970-01-01
  • 1970-01-01
  • 2016-07-30
  • 2022-07-18
  • 2019-12-17
  • 2022-06-14
相关资源
最近更新 更多