D
dev2
Unregistered / Unconfirmed
GUEST, unregistred user!
多谢各位!
依据各位的练功心法,静心修炼,终于练成“关联功”,多谢!
折腾这么长时间,原来是小第对“指针心法“难以融会贯通,不过也终于
打通了!
附:
type
PMyRec = ^TMyRec;
TMyRec = record
id: integer;
end;
1. ListView关联
with User do
begin
while not Eof do
begin
new(MyRecPtr);
MyRecPtr^.id := fieldByName('UserID').asInteger;
item := ListView1.Items.add;
item.Caption := fieldByName('UserID').asstring;
item.SubItems.Add (fieldByName('UserName').asstring);
item.Data := MyRecPtr;
next;
end;
end;
2.数据获取
procedure TForm1.ListView1Click(Sender: TObject);
begin
if ListView1.Selected <> nil then
Label4.caption := IntToStr(PMyRec(ListView1.Selected.Data)^.ID);
end;
3。指针释放
for i := 0 to ListView1.items.count -1 do
dispose(Pint(ListView1.items.Data)); //
TreeView同理。
多谢!!!
依据各位的练功心法,静心修炼,终于练成“关联功”,多谢!
折腾这么长时间,原来是小第对“指针心法“难以融会贯通,不过也终于
打通了!
附:
type
PMyRec = ^TMyRec;
TMyRec = record
id: integer;
end;
1. ListView关联
with User do
begin
while not Eof do
begin
new(MyRecPtr);
MyRecPtr^.id := fieldByName('UserID').asInteger;
item := ListView1.Items.add;
item.Caption := fieldByName('UserID').asstring;
item.SubItems.Add (fieldByName('UserName').asstring);
item.Data := MyRecPtr;
next;
end;
end;
2.数据获取
procedure TForm1.ListView1Click(Sender: TObject);
begin
if ListView1.Selected <> nil then
Label4.caption := IntToStr(PMyRec(ListView1.Selected.Data)^.ID);
end;
3。指针释放
for i := 0 to ListView1.items.count -1 do
dispose(Pint(ListView1.items.Data)); //
TreeView同理。
多谢!!!