Einzelnen Beitrag anzeigen

Benutzerbild von s.h.a.r.k
s.h.a.r.k

Registriert seit: 26. Mai 2004
3.159 Beiträge
 
#9

Re: Unterkategorien bei Komponenten

  Alt 25. Nov 2005, 11:15
Hey!
Mein Kollege hat grad ein Delphi 5 Kochbuch (oder wie das heißt) aufgetrieben und da stand die Lösnug meines Problems exakt drin:

Delphi-Quellcode:
type
  class TAnything = class
    private
      FInt1, FInt2: integer;
      FStr: string;
    published
      property Int1: integer read FInt1 write FInt1;
      property Int2: integer read FInt2 write FInt2;
      property Str: string read FStr write FStr;
  end;
     
  TMyControl = class(TComponent)
    private
      FTest: TAnything;
    public
      constructor Create(AOwner: TComponent); override;
      destructor Destroy;
    published
      property Test: TAnything read FTest write FTest;
  end;

...
implementation
...

constructor TMyControl.Create(AOwner: TComponent); override;
begin
  inherited Create(AOwner);
  FTest := TAnything.Create;
end;

destructor TMyControl.Destroy;
begin
  FTest.Free;
  inherited Destroy;
end;
Also so hat es bei mir funktioniert. Ich hoffe ich, dass ich keinen Schreibfehler drin hab, da ich auf diesem Rechner hier leider kein Delphi hab. Somit sind alle Angaben ohne Gewehr
»Remember, the future maintainer is the person you should be writing code for, not the compiler.« (Nick Hodges)
  Mit Zitat antworten Zitat