WinForms:具有不同图像大小的ListView的ImageList [英] WinForms: ImageList for ListView with different image sizes

查看:102
本文介绍了WinForms:具有不同图像大小的ListView的ImageList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ListView,其View属性设置为LargeIcon.我有一个ImageList作为ListView的图像源.

I have a ListView with View property set to LargeIcon. And I have an ImageList as image source for ListView.

我想要在ListView中同时显示垂直和水平方向的图像,但是ImageList对于其集合中的所有图像都只有一个属性ImageSize,例如,如果我将该属性设置为150x100并添加一个垂直图像(100x150)收集-ListView自动将其拉伸到150x100.

What I want is to display both vertically and horizontally oriented images in ListView but ImageList have only a single property ImageSize for all images in its collection so for example if I set that property to 150x100 and add a vertical image (100x150) to collection - ListView automatically stretches it to 150x100.

据我所知,我需要一些ImageList,其中每个图像均以其原始大小存储.关于如何做到这一点的任何想法? 预先感谢.

So as I understand I need some ImageList, in which every image is stored with its original size. Any thoughts about how to do that? Thanks in advance.

推荐答案

我自己遇到了这个问题,这是我所做的,希望它也能对您有所帮助,首先确定您将使用的最大图像尺寸(用于例如200x200),然后使用具有透明背景的Png或Gif图像(全部为200x200).

I have had this problem myself, Here is what I did, I hope it will help you as well, first determine the biggest image size you would use ( for example 200x200) then use Png or Gif images (all 200x200) with transparent backgrounds.

以我创建的两个图像为例.

have a look at these two images i have created as an example.

但是我这样做是为了避免拉伸:

but I make it like this to avoid stretching:

这篇关于WinForms:具有不同图像大小的ListView的ImageList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆