Generic components with published properties.

Giganews Newsgroups
Subject:Generic components with published properties.
Posted by: Daniel Bartlett
Date:Tue, 30 Sep 2008

If I write button that has a generic property, then install it into Delphi, the published properties that are generic won't appear in the object inspector.

  TGenericButton<T> = class(TButton)
  private
    FASomething: T;
    FAnInteger: Integer;
  published
    property AnInteger: Integer read FAnInteger write FAnInteger;
    property ASomething: T read FASomething write FASomething;
  end;

  TIntegerButton = class(TGenericButton<Integer>)
  end;

  procedure Register;

implementation

  procedure Register;
  begin
    RegisterComponents('My Generic Components',[TIntegerButton]);
  end;

In the object inspector, AnInteger property is visible, but ASomething property is not.

This is a bug isn't it, or something else?

Also, if you use TIntegerButton = TGenericButton<Integer>, instead of TIntegerButton = class(TGenericButton<Integer>), it can't name the components correctly, you get an error when placing them onto a form "GenericButton<System.Integer>1 is not a valid component name"

Replies