ImageList Transparency not working at runtime
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?
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
精彩评论