C# 如何更改Listview的现有Imagelist图像大小

C# 如何更改Listview的现有Imagelist图像大小,c#,C#,我试图在listview处于活动状态且包含项目时更改imagelist图像大小。但它似乎只影响新添加的图像,现有图像将变为空白 这是我的密码: public Form1() { ... imglst_ = new ImageList(); imglst_.ImageSize = new Size(80, 80); listView1.SmallImageList = imglst_; listView1.LargeImageList = imglst_;

我试图在listview处于活动状态且包含项目时更改imagelist图像大小。但它似乎只影响新添加的图像,现有图像将变为空白

这是我的密码:

public Form1()
{
    ...
    imglst_ = new ImageList();
    imglst_.ImageSize = new Size(80, 80);
    listView1.SmallImageList = imglst_;
    listView1.LargeImageList = imglst_;
    ...
}

//zoom in
//This code only affect the new added image
//the existing images will become blank
private void toolStripZoomin_Click(object sender, EventArgs e)
{
    int w = imglst_.ImageSize.Width;
    int h = imglst_.ImageSize.Height;

    w = (int)(w * 1.2);
    h = (int)(h * 1.2);

    imglst_.ImageSize = new Size(w, h);
}
财产文件规定:

在将图像添加到图像集合之前设置
ImageSize
属性会将图像大小调整为指定的图像大小

ImageSize
属性设置为新值时,该属性的
句柄
重新创建图像列表

因为设置
ImageSize
属性会导致句柄 重新创建,您应该在设置图像之前设置图像大小 属性。创建
图像列表的句柄时,设置
设置后,代码中的
ColorDepth
ImageSize
属性 Images属性,将导致为 要删除的图像属性

因此,添加图像后不能更改
ImageSize
,应在设置
ImageSize
后将图像再次添加到
ImageList
,以便以新指定的大小绘制图像