Hello StackOverFlow社区,
我正在尝试在listview中加载超过一千个图像但是我得到了OutOfMemoryException。我希望能够在用户向下滚动时加载图像,就像延迟加载体验一样。我怎样才能成功实现以下c#代码?
private void btnAddImg_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
DialogResult dr = ofd.ShowDialog();
if(dr == DialogResult.OK)
{
foreach (string filename in ofd.FileNames)
{
Image img = Image.FromFile(filename);
string a = c.ToString();
imageList1.Images.Add(a, img);
var listViewItem = listView1.Items.Add("");
listViewItem.ImageKey = a;
c++;
}
}
}