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.
timer事件
try
if not Assigned(Users) then
Exit;
AuxTimer.Enabled := False;
if ListViewThread.Items.Count <> Users.ThreadCache.count then
ListViewThread.Items.Count := Users.ThreadCache.count;
ListViewThread.Refresh;
finally
AuxTimer.Enabled := True;
end;
在Listview 的ondata事件里:
if not Assigned(Users) then
Exit;
UserSocket := users.ViewUser(Item.Index);
if UserSocket <> nil then
with Item, UserSocket do
begin
if FSocket = INVALID_SOCKET then
begin
if OnLine then
Caption := '断开'
else
Caption := '关闭';
end
else
Caption := '保持';
bug:='594';
SubItems.Add(CurrentAction);
SubItems.Add(FundAccount);
SubItems.Add(UserName);
SubItems.Add(ComeFrom);
SubItems.Add(inttostr(ReqCount));
SubItems.Add(inttostr(ReqBytes));
SubItems.Add(inttostr(AnsBytes));
SubItems.Add(inttostr(LastReqBytes));
SubItems.Add(inttostr(LastAnsBytes));
SubItems.Add(FormatDateTime('hh:nn:ss.zzz', LastReqTime));
SubItems.Add(FormatDateTime('hh:nn:ss.zzz', LastAnsTime));
if LastAnsTime >= LastReqTime then
SubItems.Add(Format('%.3f', [LastAccessTimeCount / 1000]))
else
SubItems.Add('--.---');
SubItems.Add(FormatDateTime('hh:nn:ss.zzz', LoginTime));
SubItems.Add(inttostr(LastCVTType));
SubItems.Add(FromAddress);
end;