请教ListView如何在里面根据数据库一表记录自动添加个数啊,而且添加图标不一样啊?
table 字段 t1,t2 放一个ImageList1控件。
t1='1'是添加图标序列1;名字为‘T1’
t1='2'是添加图标序列2 名字为‘T2’
多谢???

解决方案 »

  1.   

    图标要之前放在imagelist里面,名字产生代码控制,并且显示不同图标就用不同的ImageIndex实现.比如T1,那么ImageIndex就为1.
      

  2.   

    就是往ListView添加项目,添加时能从ImageList1取出图像,图像序列可定义
      

  3.   

    table.first;
    ListView.Items.Clear;
    while not table.eof do
    begin
      with ListView do
      begin
        Caption := 'T'+table.FieldByName('T1').AsString;
        ImageIndex := table.FieldByName('T1').AsInteger;
      end;
      table.next;
    end;
    --事先在 ImageList 中放好了图标,并且 T1 字段的值代表的图标与 ImageList 的一致。
      

  4.   

    呵呵,就是这个意思。wgqcsdn(wgq) 理解的思路正确。
      

  5.   

    楼上 ImageIndex错误啊,具体点啊!
      

  6.   

    写错了!应该是:
    table.first;
    ListView.Items.Clear;
    while not table.eof do
    begin
      with ListView.Items.Add do //这句写错了
      begin
        Caption := 'T'+table.FieldByName('T1').AsString;
        ImageIndex := table.FieldByName('T1').AsInteger;
      end;
      table.next;
    end;