listbox与mapx关联,删除老出错,大家帮忙啊(100分)

  • 主题发起人 weiyancheng1181
  • 开始时间
W

weiyancheng1181

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TF_main.UpdateCarList;
var iSelect,count:integer;
begin
iSelect := Listbox1.ItemIndex;
ListBox1.Clear;
for count := 1 to iCount do
ListBox1.Items.Add(fArray[count-1].sName);
ListBox1.ItemIndex := iSelect;

end;
后边是删除:
procedure Tf_main.BitBtn21Click(Sender: TObject);
var
select : variant;//cmapxselection;
i,j,k : integer;
lyr,l : cmapxlayer;
begin
i := 2;
begin
if (listbox1.ItemIndex=-1) then
messagedlg('没有标注目标被选中!',mtcustom,[mbok],0)
else
begin
lyr := map1.Layers.Item(i);
select := lyr.Selection; //选中图元
l:=map1.Layers.AnimationLayer;
lyr.Editable := true;
for j := 1 to select.count do
begin
lyr.DeleteFeature(select.item(j));
//if (lyr.Name='CQ_DL1') then
// begin
listbox1.Items.Delete(iNum);

{ for k:=1 to lyr.AllFeatures.Count do
if (listbox1.Items.Names[k] = select.item(j).name) then
listbox1.Items.Delete(k);

map1.Layers.AnimationLayer.Refresh;
// end;}
end;
end;

end;

end;
 
select删除的时候是变化的,所以
for j := 1 to select.count do 这个会有问题哦
 
那位高手给出解决方案阿?
最好使用代码讲话,理论偶听不懂。。。
 
for j := 1 to select.count do
改成这样的
for j:=select.count download to 1 do
 
顶部