请问imageList.TransparentColor属性
imageList.TransparentColor属性:获取或设置被视为透明的颜色。MSDN:http://msdn.microsoft.com/zh-cn/library/system.windows.forms.imagelist.transparentcolor(v=VS.100).aspx
如图,有一个button1控件,设置与imageList1关联,把btton1的背景设置为蓝色,有一小块全部是白色的图片,然后,设置
imageList1.TransparentColor = Color.FromArgb(255, 255, 255);
那就意味着把白色设置为透明,那么那块全白色的图片就应该是透明的吧,也就意味着应该显示button1的背景色,即蓝色。
可事实上,为什么不是这样的呢?
谢谢!!!
--------------------编程问答-------------------- 等待答案 --------------------编程问答-------------------- ImageList做的透明处理是在Load或设定图像的时候处理:
imageList.Images.Add(image);
imageList.Images[i]=image;
对于已经存在于list中的图像,设置了TransparentColor也不会起什么作用,TransparentColor只会影响到后续添加的图像
不过你的要求可以通过下面代码实现
int index = button2.ImageIndex;
imageList1.Images[index] = imageList1.Images[index];
button2.Refresh();
补充:.NET技术 , C#