Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.GetMyContact(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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
783 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...