我在程序中用了一个listview,用于显示操作结果,但是我已经注意释放资源了呀,用的是:listview.clear或者是listview.items.delete;程序持续长时间运行后,出错,弹出系统出错提示框:list out of bounds,这个该怎么解决哪?

解决方案 »

  1.   

    是你操作时候出的问题,不存在你操作的项目;ITEM;
      

  2.   

    原因是你的程序操作错误,Item的Index可能大于Items.Count,或者小于它;请仔细检查一下!
      

  3.   

    程序中涉及listview的代码如下:
    procedure TSmsSendThread.DispSmsSendMsg(sendtype,uid,content,sendtime,bz:string);
    var
    Listitem :Tlistitem;
    begin
        with frmmain.Lv_SmsSend do
        begin
        if Items.Count >= 20 then
            Items.Delete(0);
        ListItem := Items.Add;
        ListItem.caption := SendType;
          ListItem.SubItems.Add(Sendtime);
          ListItem.SubItems.Add(content);
         Scroll(0,10);
        end;
    end;
      

  4.   

    附加代码: if LvUser.Items.Count >= 100 then
            LvUser.Clear;
        ListItem := LvUser.Items.Add;
        ListItem.caption := userid;
        ListItem.SubItems.Add(pwd);
        ListItem.SubItems.Add(msg);
    这个不会有问题吧。
    不好意思,我好像有点不用脑子自己去想一想,其实我想了很久,脑袋都想破了,我现在没办法,只有叫客户每天去重启一下程序,谢谢大家了