你可以定义一个结构,对所有类型都可以
PMyRecord=^TMyREcord;
TMyRecord=record
MyStr:String;
MyInt:Integer;
end========
Var
MyREcord :PMyRecord;
Begin
New(MyRecord);
MyRecord.MyStr :='dssad';
MyREcord.MyInt :=10;
ListBox.Items.Addobject('Test Str',MyRecord);
...
end;========
Var
MyREcord :PMyRecord;
sStr :String;
iInt :Integer;
Begin
MyRecord :=PMyRecord(ListBox.Items[0].Data);
sStr :=MyRecord.MyStr;
iInt :=MyRecord.MyInt;
end;
==========
Var
MyRecord :PMyrecord;
i:Integer;
Begin
for i :=0 to ListBox.Items.Count -1 do
Begin
MyRecord :=PMyRecord(ListBox.Items[i].Data);
Dispose(MyRecord);//记住要释放内存
end;
end;
PMyRecord=^TMyREcord;
TMyRecord=record
MyStr:String;
MyInt:Integer;
end========
Var
MyREcord :PMyRecord;
Begin
New(MyRecord);
MyRecord.MyStr :='dssad';
MyREcord.MyInt :=10;
ListBox.Items.Addobject('Test Str',MyRecord);
...
end;========
Var
MyREcord :PMyRecord;
sStr :String;
iInt :Integer;
Begin
MyRecord :=PMyRecord(ListBox.Items[0].Data);
sStr :=MyRecord.MyStr;
iInt :=MyRecord.MyInt;
end;
==========
Var
MyRecord :PMyrecord;
i:Integer;
Begin
for i :=0 to ListBox.Items.Count -1 do
Begin
MyRecord :=PMyRecord(ListBox.Items[i].Data);
Dispose(MyRecord);//记住要释放内存
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货