델파이/Components

Component 에 TStringList 넣기

지병철 2012. 2. 6. 16:38


unit ControlPanelItem;

interface

uses
 
SysUtils, Classes, Controls, ExtCtrls, Graphics, AdvPanel, StdCtrls,
 
Windows,Forms,Dialogs;

type
  tControlPanelItem
= class(TAdvPanel)
 
private
    fLinesText
: TStrings;
    procedure
SetLinesText(const Value: TStrings);
    procedure
SetText;
 
protected
 
public
    constructor
Create(AOwner : TComponent); override;
    destructor
Destroy; override;
  published
    property
NewLinesText  : TStrings read FLinesText write SetLinesText;
 
end;

procedure
Register;

implementation

procedure
Register;
begin
 
RegisterComponents('Samples', [tControlPanelItem]);
end;

constructor tControlPanelItem
.Create(AOwner: TComponent);
begin
  inherited
;
  fLinesText
:= TStringList.Create;
end;

destructor tControlPanelItem
.Destroy;
begin
  fLinesText
.Free;
  inherited
;
end;

procedure tControlPanelItem
.SetLinesText(const Value: TStrings);
begin
  fLinesText
.Assign(value);
 
SetText;
end;

procedure tControlPanelItem
.SetText;
var
   count
: Integer;
begin
 
for count := 0 to fLinesText.Count - 1 do
 
ShowMessage(fLinesText.strings[count]);

end;

end.