簡體   English   中英

如何在虛擬模式下顯示所有列表視圖項目上的圖標(C#)

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

我正在使用listview的虛擬模式來顯示大數據。 但我不知道如何顯示每個項目的圖像。 誰能幫我 ?

我寫

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";
        }
    }

但它不能正常工作

這似乎是.NET Framework中的一個錯誤(已被標記為無法修復 )。 你可能想看看這個 解決方案是使用ImageIndex而不是ImageKey

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM