function ShowListView(ClientDataSet : TClientDataSet; ListView : TListView; ImageIndex : Integer) : Integer;
var
i, j : Integer;
ListItem : TListItem;
begin
ListView.Items.Clear;
with ClientDataSet do
begin
if Active = True
then
First
else
Open;
for i := 0 to RecordCount - 1 do
begin
with ListView.Items do
begin
ListItem := Add ;
for j := 0 to Fields.Count - 1 do
With Item do
begin
if j = 0 then
ListItem.Caption := Fields[j].AsString
else
begin
if Fields[j].DataType = ftDateTime then
begin
if TimeToStr(Fields[j].AsDateTime) = '0:00:00' then
ListItem.SubItems.Add(Fields[j].AsString + ' 0:00:00')
else
ListItem.SubItems.Add(Fields[j].AsString);
end
else
ListItem.SubItems.Add(Fields[j].AsString);
end;
end;
ListItem.ImageIndex := ImageIndex;
Next;
end;
end;
end;
Result := 0;
end;