不知道谁有这两个控件的使用帮助或者实例,谢谢啦,
while (not DM.AdoTmpQuery2.eof) do
   begin
    listview1.Items.Add.Caption:=dm.AdoTmpQuery2.fieldbyname('foldername').asstring;
        listview1.Items.Item[i].ImageIndex :=9;
        DM.AdoTmpQuery2.next;
      end;
我本意要对这个项进行相同的图标设置可是不行,为什么啊?

解决方案 »

  1.   

    你的基础没有过关,应该这样写:
    var
      item:TListItem;
    begin
    while (not DM.AdoTmpQuery2.eof) do
       begin
         item:= listview1.Items.Add;
         item.Caption:=dm.AdoTmpQuery2.fieldbyname('foldername').asstring;
         Item.ImageIndex :=9;
         DM.AdoTmpQuery2.next;
       end;
    end;
      

  2.   

    你的i变量来自何处?建议使用 fei19790920(饭桶的马甲) 的方法
      

  3.   

    或者
    var
      item:TListItem;
    begin
    while (not DM.AdoTmpQuery2.eof) do
       begin
         with listview1.Items.Add do
         begin
           Caption:=dm.AdoTmpQuery2.fieldbyname('foldername').asstring;
           ImageIndex :=9;
         end;
         DM.AdoTmpQuery2.next;
       end;
    end;