开发者

How to show icon on all listview items in virtual mode (C#)

开发者 https://www.devze.com 2023-02-26 10:08 出处:网络
I\'m using virtual mode of listview to show a larg data. But I don\'t know how to show image for each item. Who can help me ?

I'm using virtual mode of listview to show a larg data. But I don't know how to show image for each item. Who can help me ?

I wrote

private void ListContact_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
    {
        MyContact contact = ContactData.GetMyContac开发者_开发技巧t(e.ItemIndex);
        if (e.Item == null) e.Item = new ListViewItem(contact.ToString());
        if (contact.Photo != null)
        {
            e.Item.ImageList.Images.Add("" + contact.Id, contact.Photo);
            e.Item.ImageKey = "" + contact.Id;
        }
        else
        {
            e.Item.ImageKey = "default";
        }
    }

But it don't work properly


This seems to be a bug in the .NET Framework (that's been marked as Won't fix). You might want to check this out. The solution would be to use ImageIndex instead of ImageKey.

0

精彩评论

暂无评论...
验证码 换一张
取 消