如何显示在虚拟模式下,所有列表视图项的图标(C#) [英] How to show icon on all listview items in virtual mode (C#)
本文介绍了如何显示在虚拟模式下,所有列表视图项的图标(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的ListView的虚拟模式,显示一个LARG数据。但我不知道如何显示图像的每个项目。谁可以帮我?
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 ?
我写了
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
推荐答案
这似乎是在.NET Framework中的错误(这就是被标记为将不修复)。您可能要检查<一个href=\"https://connect.microsoft.com/VisualStudio/feedback/details/430731/listview-fails-to-display-image-set-by-key-when-in-virtual-mode\">this出。该解决方案是使用的ImageIndex
而不是 ImageKey
。
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
.
这篇关于如何显示在虚拟模式下,所有列表视图项的图标(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文