开发者

ImageList Transparency not working at runtime

开发者 https://www.devze.com 2022-12-12 06:08 出处:网络
I am using 32bit PNG files with transparency. I added them to an image list with properties: ColorDepth: Depth32Bit

I am using 32bit PNG files with transparency. I added them to an image list with properties:

ColorDepth: Depth32Bit
TransparentColor: Transpa开发者_运维知识库rent

When I assign the image to my toolbar button, it previews in Visual Studio fine with the correct transparency. But when I run the application the transparency is all messed up with black covering the semi-transparent regions.

How do I fix this?

ImageList Transparency not working at runtime

ImageList Transparency not working at runtime


If you add them directly to the toolbar without using an image list I think they will draw correctly.


The solution apparently is to put

Application.EnableVisualStyles();

Before the start of your application. This has fixed the transparency issue.

Solution Reference

MSDN on EnableVisualStyles

0

精彩评论

暂无评论...
验证码 换一张
取 消