有关于DELPHI的TCOLLECTION及TCOLLECTIONITEM类的使用??

morphia 2001-07-30 10:24:44
下面是一个完整的控件单元的代码,可以安装至DELPHI中。
但是!有一个很重要的问题出现了,在Test控件中的TTestCollection
属性可以点开,但是在TTestCollectionItem对象中的TTestSubCollection
属性却点不开了,难道TCollection不可以套用吗?还是我的类写得不正确?

能够解决这些问题的人快快回答我吧,我先谢谢了。 (分数可以再加,谢谢)

unit Test;

interface

uses
Classes;

type
TTestSubCollectionItem = class(TCollectionItem)
private
FProp004: Integer;
FProp003: string;
procedure SetProp003(const Value: string);
procedure SetProp004(const Value: Integer);
published
property Prop003: string read FProp003 write SetProp003;
property Prop004: Integer read FProp004 write SetProp004;
end;

TTestSubCollection = class(TCollection)

end;

TTestCollectionItem = class(TCollectionItem)
private
FProp02: Integer;
FProp01: string;
FSubCollection: TTestSubCollection;
procedure SetProp01(const Value: string);
procedure SetProp02(const Value: Integer);
procedure SetSubCollection(const Value: TTestSubCollection);
public
constructor Create(Collection: TCollection); override;
published
property Prop01: string read FProp01 write SetProp01;
property Prop02: Integer read FProp02 write SetProp02;
property SubCollection: TTestSubCollection read FSubCollection write SetSubCollection;
end;

TTestCollection = class(TCollection)

end;

TTest = class(TComponent)
private
FTestCollection: TTestCollection;
procedure SetTestCollection(const Value: TTestCollection);
public
constructor Create(AOwner: TComponent); override;
published
property TestCollection: TTestCollection read FTestCollection write SetTestCollection;
end;

procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Test', [TTest]);
end;

{ TTestCollectionItem }

constructor TTestCollectionItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FSubCollection := TTestSubCollection.Create(TTestSubCollectionItem);
end;

procedure TTestCollectionItem.SetProp01(const Value: string);
begin
FProp01 := Value;
end;

procedure TTestCollectionItem.SetProp02(const Value: Integer);
begin
FProp02 := Value;
end;

procedure TTestCollectionItem.SetSubCollection(
const Value: TTestSubCollection);
begin
FSubCollection.Assign(Value);
end;

{ TTest }

constructor TTest.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FTestCollection := TTestCollection.Create(TTestCollectionItem);
end;

procedure TTest.SetTestCollection(const Value: TTestCollection);
begin
FTestCollection.Assign(Value);
end;

{ TTestSubCollectionItem }

procedure TTestSubCollectionItem.SetProp003(const Value: string);
begin
FProp003 := Value;
end;

procedure TTestSubCollectionItem.SetProp004(const Value: Integer);
begin
FProp004 := Value;
end;

end.
...全文
531 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
skt985 2002-01-11
  • 打赏
  • 举报
回复
31530关注! :)
ExitWindows 2001-07-31
  • 打赏
  • 举报
回复
up
morphia 2001-07-31
  • 打赏
  • 举报
回复
啊,已经解决,GETOWNER方法一定要覆盖,呵呵,高兴死了,谢谢谢谢谢谢谢谢!

给victorchen_2000分喽
morphia 2001-07-31
  • 打赏
  • 举报
回复
这个跟定义无关吧,TCOLLECTION本身就可以了,不需要覆盖任何PROTECTED方法,它只是
需要在CREATE的时候代入它管理的ITEM的类类型就应该可以运作,但是,为什么第一层的
COLLECTION可以运行,但是第二层的COLLECTION不可以运行呢???

高手,在哪?????

已经加了3分了,只有这么多可以加,到了明天再加3分!
victorchen_2000 2001-07-31
  • 打赏
  • 举报
回复
没有定义完整!
TTestSubCollection = class(TCollection)
TTestCollection = class(TCollection)
你可以看看src\vcl下的pas 文件,其中有StatusBar的原码。

morphia 2001-07-31
  • 打赏
  • 举报
回复
up
morphia 2001-07-31
  • 打赏
  • 举报
回复
up
morphia 2001-07-30
  • 打赏
  • 举报
回复
拜托拜托,求求回答!!!!!!!!!!!!!

谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢!!!
内容概要:本文系统研究了构网型变流器的正负序阻抗解耦特性及其在弱电网环境下的稳定性表现,重点依托Matlab/Simulink仿真平台,构建了详细的阻抗数学模型,设计了解耦控制策略,并采用小信号扫频法进行频域辨识与稳定性验证。研究深入探讨了构网型变流器与传统跟网型逆变器在正负序阻抗特性上的本质差异,结合虚拟同步发电机(VSG)等先进控制技术,分析其在抑制宽频带振荡、削弱锁相环动态耦合等方面的优越性。文中不仅提供了完整的仿真模型与MATLAB代码实现,还整合了光伏、风电、储能、微电网等多新能源系统的阻抗建模与稳定性分析资源,形成了一套面向新型电力系统稳定性的综合性技术资料体系,具有较强的科研复现与工程参考价值。; 适合人群:面向具备电力电子、电力系统自动化、新能源并网等专业背景的研究生、高校教师及工程技术人员,特别适用于从事阻抗建模、小干扰稳定性分析、宽频振荡机理研究以及撰写高水平学术论文的科研工作者。; 使用场景及目标:①掌握构网型变流器正负序阻抗建模与扫频辨识的仿真方法;②深入理解VSG等构网型控制在弱电网中提升稳定性的内在机理;③复现顶刊论文中的阻抗分析流程与稳定性判据应用;④利用提供的成熟模型与代码加速科研进程,支撑课题研究与学术成果产出。; 阅读建议:建议结合文中提供的Simulink模型与MATLAB代码,按照“理论建模—仿真搭建—扫频激励—频响提取—Nyquist判据分析”的完整流程进行实践操作,重点关注扫频信号的注入方式、频率范围设置及阻抗曲线的物理意义解读,并参考博士论文复现案例深化对复杂动态耦合问题的理解。

5,943

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧