property Objects[Index: Integer]: TObject read GetObject write SetObject;
解决方案 »
- 远程主机强迫关掉一个连接
- 100分求教:模拟按键问题
- 关于IdTCPClient和IdTCPServer控件的菜鸟问题
- c/s编程的经验问题?
- 如何访问单个网格的Color属性,也就是Font属性?(不要嫌分少)
- to yifei1900(逸飞) 及各位高手!来看看这个SQL 语句那里错了!
- 在Delphi7中如何使用XP的窗体?
- 高手请看一下:这个问题是不是需要用线程来控制
- 如何设置ADO数据表的过滤条件?
- help me:http://www.csdn.net/expert/topic/373/373660.shtm
- 哪个API函数可以将文件夹设为完全共享
- 请问各位高手《Delphi 6程序设计从入门到精通》里的例子代码谁有?
有两种方法:
(1)使用集合对象,即TCollection类对象。
(2)使用动态数组:
type
TObjectDynArray = array of TObject;private
GetObjects: TObjectDynArray;
procedure SetObjects(AObjects: TObjectDynArray);
published
property Objects: TObjectDynArray read GetObjects write SetObjects(AObject: TObjectDynArray);
end;
property Objects: TObjectDynArray read GetObjects write SetObjects;
应该可以的吧,我试过没有问题呀?
function GetObject(iIndex: Integer): TObject;
procedure SetObject(iIndex: Integer; AObject: TObject);不能象我那样:
function GetObject: TObject);
procedure SetObject(AObject: TObject);嗯,正谈着恋爱,果然智商下降很多,而且有些形而上学呢。
写完
property Objects[Index: Integer]: TObject read GetObject write SetObject;
后,按Ctrl-Shift-C,就可以自动生成那些代码了。
delphi7会这样说:
[Error] Unit1.pas(17): Published property 'A' cannot be of type ARRAY
private
Fa :array [0..1] of integer;
{ Private declarations }
public
{ Public declarations }
published
property A[index:integer] : integer read geta write seta;
end;
function GetA(Index:Integer):Integer;Virtual;Abstract;
Procedure SetA(Index:Integer;const val:Integer);Virtual;
数组属性只能是public
如果要放在published要自己定义属性编辑器。