【问题标题】:Dynamically change listview icon size in c#在 C# 中动态更改列表视图图标大小
【发布时间】:2019-02-15 10:10:59
【问题描述】:

我正在尝试制作带有选项的列表视图。选项之一是更改图标大小。我试图做出这样的改变:

this.listview1.LargeImageList.ImageSize = this.list.SmallImageList.ImageSize = new Size(h, w);

这改变了图像大小,但图像消失了。谁能帮帮我?

【问题讨论】:

    标签: c# winforms icons


    【解决方案1】:

    请看下面的链接,我觉得应该有用:

    How to Change existing Imagelist image size of Listview

    使用以下代码。它对我有用:

    listView1.View = View.LargeIcon;
    ImageList iList = new ImageList();
    iList.ImageSize = new Size(128, 128);
    iList.ColorDepth = ColorDepth.Depth32Bit;
    iList.Images.Add(Properties.Resources.x64_Clear_icon); 
    listView1.LargeImageList = iList;
    

    【讨论】:

    • 我尝试重新创建 LargeImageList 和 SmallImageList,但图像正在改变(最终图像为灰色)。我这样做的方式是:
    • ImageList tmp = new ImageList(); tmp.ImageSize = 新尺寸(h,w); foreach(this.list.LargeImageList.Images 中的图像 img){ tmp.Images.Add(img); } this.list.LargeImageList = this.list.SmallImageList = tmp;
    • 使用以下代码。它对我有用:listView1.View = View.LargeIcon; ImageList iList = new ImageList(); iList.ImageSize = 新尺寸(128, 128); iList.ColorDepth = ColorDepth.Depth32Bit; iList.Images.Add(Properties.Resources.x64_Clear_icon); listView1.LargeImageList = iList;
    猜你喜欢
    • 2013-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多