T TIGER@DELPHI Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #1 这个类要有个可以编辑的属性,类型是TSTRINGS,用户可以通过在设计期的属性编辑器里把 LINES输入进去,并且保存在这个类的内部变量中,象MEMO的LINES那样,我应该怎么写呢???
T TIGER@DELPHI Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #2 这个类要有个可以编辑的属性,类型是TSTRINGS,用户可以通过在设计期的属性编辑器里把 LINES输入进去,并且保存在这个类的内部变量中,象MEMO的LINES那样,我应该怎么写呢???
T TIGER@DELPHI Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #4 我现在发现了一个很奇怪的现象,TMemoStrings居然不能被创建? var a:tmemostrings; begin a.//这里居然说为定义TMEMOSTRINGS,可是我已经引用了相关UNIT end;
我现在发现了一个很奇怪的现象,TMemoStrings居然不能被创建? var a:tmemostrings; begin a.//这里居然说为定义TMEMOSTRINGS,可是我已经引用了相关UNIT end;
D dreamisx Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #5 var a: TStrings; begin a := TStringList.Create; ...
D dreamisx Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #6 之所以不能用TMemoStrings,是因为它的定义是在implementation之后,即除StdCtrls.pas之外的单元均不能引用,也即它是私有的。
Z ZBJ2001_KF Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #8 在类中定义私有变量 类型是TSTRINGS. 设置属性即可.
Z ZBJ2001_KF Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #9 我也试了,提示同CAN'T ASSIGN A NIL OR A TMEMOSTRINGS 你的也是吧
Z ZBJ2001_KF Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-11 #10 测试成功了 unit Unit2; interface uses classes; type tmyclass=class(tcomponent) private fstr:TStrings; procedure setstr(value:tstrings); published property fs :tstrings read fstr write SETSTR; public constructor create(AOwner: TComponent);OVERRIDE; destructor Destroy; override; end; procedure Register; implementation { tmyclass } procedure Register; begin RegisterComponents('Samples', [tmyclass]); end; constructor tmyclass.create(AOwner: TComponent); begin inherited Create(AOwner); fstr:=tstringlist.Create; end; destructor tmyclass.Destroy; begin inherited; fstr.Free; end; procedure Tmyclass.Setstr(Value: TStrings); begin if FS.Text <> Value.Text then begin // Disconnect; FS.BeginUpdate; try FS.Assign(Value); finally FS.EndUpdate; end; end; end; end.
测试成功了 unit Unit2; interface uses classes; type tmyclass=class(tcomponent) private fstr:TStrings; procedure setstr(value:tstrings); published property fs :tstrings read fstr write SETSTR; public constructor create(AOwner: TComponent);OVERRIDE; destructor Destroy; override; end; procedure Register; implementation { tmyclass } procedure Register; begin RegisterComponents('Samples', [tmyclass]); end; constructor tmyclass.create(AOwner: TComponent); begin inherited Create(AOwner); fstr:=tstringlist.Create; end; destructor tmyclass.Destroy; begin inherited; fstr.Free; end; procedure Tmyclass.Setstr(Value: TStrings); begin if FS.Text <> Value.Text then begin // Disconnect; FS.BeginUpdate; try FS.Assign(Value); finally FS.EndUpdate; end; end; end; end.
Z zjan521 Unregistered / Unconfirmed GUEST, unregistred user! 2005-08-18 #12 //来自:ZBJ2001_KF, 时间:2005-8-11 19:32:05, ID:3164024 destructor tmyclass.Destroy; begin fstr.Free;//换一下顺序。虽然你的不会出什么错,不过这是因为简单. inherited; end; procedure Tmyclass.Setstr(Value: TStrings); begin FS.Assign(Value);//不要那么复杂 end;
//来自:ZBJ2001_KF, 时间:2005-8-11 19:32:05, ID:3164024 destructor tmyclass.Destroy; begin fstr.Free;//换一下顺序。虽然你的不会出什么错,不过这是因为简单. inherited; end; procedure Tmyclass.Setstr(Value: TStrings); begin FS.Assign(Value);//不要那么复杂 end;