提醒你,不要使用TStrings,要使用他的继承类。
下面是一个示例:
{
沈前卫 2000-2-11 2:29
在Dell 233MHz+Win98+Delphi4(Build5.33)下测试通过!
注意:
转贴请保持本文的完整性
}
unit MyMemo;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ScktComp,stdctrls,dsgnintf;
type
TMyListProperty=class(TClassProperty)
public
function GetAttributes:TPropertyAttributes;override;
procedure Edit;override;
end;
TMyMemo = class(TMemo)
private
{ Private declarations }
FMyList:TStringList;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent);override;
destructor Destroy;override;
published
{ Published declarations }
property MyList:TStringList read FMyList write FMyList;
end;
procedure Register;
implementation
function TMyListProperty.GetAttributes:TPropertyAttributes;
begin
Result:=inherited GetAttributes+[paDialog]-[paSubProperties];
end;
{自己建立一个From接受输入数据,用ShowModal显示}
procedure TMyListProperty.Edit;
var
tmpMyList:TStringList;
begin
tmpMyList:=TStringList(GetOrdValue);
tmpMyList.Clear;
tmpMyList.Add('shenqw1');
tmpMyList.Add('shenqw2');
tmpMyList.Add('shenqw3');
tmpMyList.Add('shenqw4');
tmpMyList.Add('shenqw5');
ShowMessage('自己建立一个From接受输入数据,用ShowModal显示');
Designer.Modified;
end;
constructor TMyMemo.Create(AOwner: TComponent);
begin
inherited;
FMyList:=TStringList.Create;
end;
destructor TMyMemo.Destroy;
begin
FMyList.Free;
inherited;
end;
procedure Register;
begin
RegisterComponents('Samples', [TMyMemo]);
RegisterPropertyEditor(TypeInfo(TStringList),
TMyMemo,'MyList',TMyListProperty);
end;
end.