首页 新闻 会员 周边

c# imagelist的ImageSize属性 大小重新设置后图标不显示?

0
悬赏园豆:5 [已解决问题] 解决于 2015-08-13 22:45

如题,我用treeview做了一个导航,使用了imagelist里面的图标

我想做的是添加一个 大图标,小图标切换的功能

设置方法是:

    //大图标

            //imageList1.ImageSize = new Size(32, 32);
            treeView1.ImageList.ImageSize = new Size(32,32);

            //小图标
            //imageList1.ImageSize = new Size(16, 16);
            treeView1.ImageList.ImageSize = new Size(16, 16);

但是重新设置后图标不见了。请问该怎么做?

问题补充:

我找到了msdn看到了如下解释,但不知道该怎么处理


https://msdn.microsoft.com/zh-SG/library/system.windows.forms.imagelist.imagesize(v=vs.100

ImageSize property prior to adding images to the image collection causes the images to be resized to the image size specified.' xml:space="preserve">在将图像添加到图像集合之前设置 ImageSize 属性,会导致将图像调整到指定的图像大小。

ImageSize property to a new value, the Handle for the image list is recreated.' xml:space="preserve">当将 ImageSize 属性设置为新值时,将重新创建图像列表的 Handle

ImageSize property causes the handle to be recreated, you should set ImageSize prior to setting the Images property.' xml:space="preserve">因为设置 ImageSize 属性会导致重新创建句柄,所以应在设置 Images 属性之前设置 ImageSize。  ImageList has been created, setting the ColorDepth or ImageSize properties in code, after setting the Images property, will cause the collection of images set for the Images property to be deleted.' xml:space="preserve">在已创建了 ImageList 的句柄时,在设置 Images 属性之后在代码中设置 ColorDepth 或 ImageSize 属性会导致为 Images 属性设置的图像集被删除。

 

不存在d的主页 不存在d | 初学一级 | 园豆:86
提问于:2015-08-13 18:17
< >
分享
最佳答案
1

这个说的很清楚啊,你重新设置大小就会清空。

你想要不同大小的图,两个ImageList啊。

收获园豆:5
爱编程的大叔 | 高人七级 |园豆:30839 | 2015-08-13 19:07

哎呀,我去!是我钻牛角尖了。。。呵呵  谢谢大叔

不存在d | 园豆:86 (初学一级) | 2015-08-13 22:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册