【问题标题】:C# ListView image icon sizeC# ListView 图像图标大小
【发布时间】:2015-07-14 04:10:59
【问题描述】:

默认情况下,C# 中ListView 中的图标非常小(可能为 16x16px)。如何增加这些图标的大小?

我尝试将ImageList 中的源图像放大,也尝试使用LargeImageList 属性,但无济于事。

我正在使用 C#、WinForms 和 .net 4.0。

【问题讨论】:

  • 我猜你正在使用 WinForm? .Net 版本是什么?
  • 是的。 WinForms 和 .net 4.0 版
  • 这里有一个很好的答案:stackoverflow.com/questions/1101149/…
  • 您可以将 ImageList.ImageSize 设置为最大为 256x256 的任何值。还要看看颜色深度!!顺便说一句:高度将决定 ListViewItemHeight

标签: c# .net winforms


【解决方案1】:

诀窍在于修改 ImageList 的 ImageSize 属性(谁会想到)?

        listView1.View = View.LargeIcon;

        ImageList iList = new ImageList();
        iList.ImageSize = new Size(64, 64);  
        iList.ColorDepth = ColorDepth.Depth32Bit;

        listView1.LargeImageList = iList;

作为奖励,记得将 ListView 的 View 属性设置为 LargeIcon 并增加 ColorDepth(如果你愿意的话)。

【讨论】:

  • 记得设置 ListView 的 View 属性,那要看他想要什么了。任何模式都可以!
【解决方案2】:

【讨论】:

  • 是的,但它仍然不能使图像变大。您还需要在 ImageList 中定义更大尺寸的图像
  • @ShiroyChoksey - 我没有说它会使图像变大。但是,如果您想显示大图像,则需要设置该属性。
猜你喜欢
  • 2012-03-11
  • 1970-01-01
  • 1970-01-01
  • 2012-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-12
相关资源
最近更新 更多