tv.Items.Clear;
TV.Items.AddFirst(nil,'root');
TV.Selected:=TV.Items.Item[0];
table1.first;
while not table1.eof do
begin
tv.Items.Add(tv.selected,table1.fields[0].asstring);
table1.next;
end;
只是讨厌线吗?设置DBGrid的OPtions就可以了,没必要用ListView的。
实在要用就:
var
s:array of const;
setlength(s,listview1.columns.count);
for i:=0 to listview1.items.count-1 do
begin
s[0]:=listview1.items.caption;
for j:=0 to listview1.items.subitems.count-1 do
s[j+1]:=listview1.items.subitems[j];
dataset.insertrecord(s);
end;