Search code examples
delphicomponentsvcl

VCL Register Properties in Category not working


I am trying to group some properties of my component.

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;

I wish to show AllowSortFilter and AllowCustomizeAndGroup in VCL under a Group named PopupMenu Settings.

So I did this :

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

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

Unfortunately this is not working, and I have no idea why. The Syntax seems to be correct get no errors . But the Group is not being created.

Regards Robert


Solution

  • I think you are possibly missing a step somewhere, because if I organise your code as I think it should be organised, then I get the result that the AllowSortFilter and AllowCustomizeAndGroup entries correctly show up in the PopUpMenuSettings category of the cxGridButton.

    Here's what I did:

    • Placed your TcxGridButton code, but not your Register procedure in a new unit, CategoryRTu (RT short for run-time). This unit does not Use DesignIntf.

    • Placed your Register procedure in a new unit CategoryDTu (DT short for DesignTime). This unit does use DesignIntf.

    • Created a new package, Category.Dpk, which Contains CategoryDTu and Requires rtl, designide, vcl, dbrtl, vcldb, dxGDIPlusD7, dxCoreD7, cxLibraryD7, dxThemeD7, cxPageControlD7, cxEditorsD7, cxDataD7, dxLayoutControlD7 and cxGridD7. The D7 suffixes are because I did this in Delphi7. Some of these might not be strictly necessary, because I created the list by adding a TcxButton to a form and then copied some of the Used units into the Requires list.

    • Compiled Category.Dpk and used Component | Install packages to install Category.Bpl.

    • Created a new project and added a TcxGrid and a TcxGridButton to it.

    • Selected cxGridButton1 in the Object Inspector, right-clicked in the OI and selected View | By Category

    And then, expanding the PopUpMenuSettings node, I see AllowSortFilter and AllowCustomizeAndGroup.