type TMyRec=record id: integer; name: string; end; PMyRec=^TMyRec;var lpMyRec: PMyRec;procedure TForm1.AddDataToList(Lst: TListBox;Qry:TADOQuery);begin with qry do begin Close; Sql.Clear; Sql.Text:=''; Open; end; while not Qry.eof do begin New(lpMyRec); lpMyRec.id:=X; lpMyRec.name:='XXX'; Lst.AddItem('XXX',Pointer(lpMyRec)); end; end; //在释放List时一定要用 for I:=0 to Listbox1.items.count-1 do begin Dispose(Listbox1.Items[I]); end;
type TMyRec=record id: integer; name: string; end; PMyRec=^TMyRec;var lpMyRec: PMyRec;procedure TForm1.AddDataToList(Lst: TListBox;Qry:TADOQuery);begin with qry do begin Close; Sql.Clear; Sql.Text:=''; Open; end; while not Qry.eof do begin New(lpMyRec); lpMyRec.id:=X; lpMyRec.name:='XXX'; Lst.AddItem('XXX',Pointer(lpMyRec)); end; end; //在释放List时一定要用 for I:=0 to Listbox1.items.count-1 do begin Dispose(Listbox1.Items[I]); end;
如
TMyRec=record
id: integer;
name: string;
...
end;
PMyRec=^TMyRec;增加一个项。
var
newItem: TListItem;
lpMyRec: PMyRec;
begin
new(lpMyRec);
lpMyRec^.id := 1;
lpMyRec^.Name := 'abc';
newItem := ListView.Items.Add;
newItem.Caption := lpMyRec^.Name;
newItem.Data := lpMyRec;
end;获取一个项edtId.Text := IntToStr(PMyRec(ListView.Items[i].Data)^.Id);
edtname.Text := PMyRec(ListView.Items[i].Data)^.Name;
...
type
TMyRec=record
id: integer;
name: string;
end;
PMyRec=^TMyRec;var
lpMyRec: PMyRec;procedure TForm1.AddDataToList(Lst: TListBox;Qry:TADOQuery);begin
with qry do
begin
Close;
Sql.Clear;
Sql.Text:='';
Open;
end;
while not Qry.eof do
begin
New(lpMyRec);
lpMyRec.id:=X;
lpMyRec.name:='XXX';
Lst.AddItem('XXX',Pointer(lpMyRec));
end;
end;
//在释放List时一定要用
for I:=0 to Listbox1.items.count-1 do
begin
Dispose(Listbox1.Items[I]);
end;
TMyRec=record
id: integer;
name: string;
end;
PMyRec=^TMyRec;var
lpMyRec: PMyRec;procedure TForm1.AddDataToList(Lst: TListBox;Qry:TADOQuery);begin
with qry do
begin
Close;
Sql.Clear;
Sql.Text:='';
Open;
end;
while not Qry.eof do
begin
New(lpMyRec);
lpMyRec.id:=X;
lpMyRec.name:='XXX';
Lst.AddItem('XXX',Pointer(lpMyRec));
end;
end;
//在释放List时一定要用
for I:=0 to Listbox1.items.count-1 do
begin
Dispose(Listbox1.Items[I]);
end;
用listview我能做出来,但为了界面美观简单,我要用combobx和listbox。
谢谢你!
用listview我能做出来,但为了界面美观简单,我要用combobx和listbox。
谢谢你!