还有就是你在添加之前,只需要设定这个list的数量如 ListView2.Items.Count = PRV.Count然后刷新她就可以了
其PRV是一个存放数据的TList类型的东东
procedure TMainForm.ListView2Data(Sender: TObject; Item: TListItem);
var
I: Integer;
begin
PRV := MResultList5.Items[Item.Index];
Item.Caption := IntToStr(PRV^[1]);
for I := 2 to StrToInt(Edit2.Text) do
Item.SubItems.Add(IntToStr(PRV^[I]));
end;
Use OnData to customize an item before it is displayed in the list view control. Set the properties of the list item in the event handler so that they appear correctly when the item is drawn.