for n := 0 to locationList.Count-1  do
   begin
      location:=locationList.Items[n];
      if (location.dlghwnd=dlghwnd)  then
      begin
        locationList.Delete(n);
      end
   end;上面的locationList是一个list,它保存的是我自己定义的一个结构体location。
而结构体中某个字段为dlghwnd。
那么我在删除的时候,想循环遍历locationList,将其中dlghwnd字段值和我当前值相等,那么就删除这个结构体。
但是后来发现这样写是有问题的,比如你删除了第二个元素,然后原来的第三个元素就成为第二个元素了,而这时的N却变为3了。所以这样写是有问题的。
不知道大家有没有好的办法?