简体   繁体   English

视觉 Styles 不工作(C# VS2010)

[英]Visual Styles not working (C# VS2010)

I have a problem with Visual Styles on my WinForm app (.net framework 2) and I fail to find any solution googling for a long time.我的 WinForm 应用程序(.net 框架 2)上的 Visual Styles 有问题,我在谷歌上搜索了很长时间都找不到任何解决方案。

The forms in this project look styled in IDE (as should be), but in runtime they appear to be with no styles applied in any OS.该项目中的 forms 看起来采用 IDE 的样式(应该如此),但在运行时它们似乎没有在任何操作系统中应用 styles。

I've tried:我试过了:

1) Put in my program.cs 1)放入我的program.cs

        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.DoEvents();

before the form creation and that doesn't help在创建表单之前,这无济于事

2) Insert System.Windows.Forms.Application.EnableVisualStyles(); 2) 插入System.Windows.Forms.Application.EnableVisualStyles(); in form constructor.在表单构造函数中。

2) delete, create new manifest that doesn't help either. 2)删除,创建新的清单也无济于事。

After some debugging I found that VisualStyleInformation.IsEnabledByUser is returning FALSE instead of True as it should be.经过一些调试后,我发现VisualStyleInformation.IsEnabledByUser返回 FALSE 而不是应该返回的 True。 I have very similar application using the same resources and libraries which works absolutely fine, with all styles applied and it is returning TRUE for IsEnabledByUser.我有非常相似的应用程序使用相同的资源和库,它们工作得非常好,应用了所有 styles,它为 IsEnabledByUser 返回 TRUE。

Does anybody have any ideas how to nail it?有没有人有任何想法如何钉它?

Next to all the actions you took, you should also make sure that the FlatStyle property of your controls is set to FlatStyle.System .在您执行的所有操作旁边,您还应该确保将控件的 FlatStyle 属性设置为FlatStyle.System Check if this true for all your controls, including your Form.检查您的所有控件是否都是如此,包括您的表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM