Windows 10 创意者更新更改了 PropertyGrid 控件的样式 [英] Windows 10 Creators Update changes the style of PropertyGrid control

查看:29
本文介绍了Windows 10 创意者更新更改了 PropertyGrid 控件的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将一些系统升级到 Windows 10 创意者更新,我注意到 Windows 窗体 PropertyGrid 控件将其标题和栏边距的默认视觉样式更改为深灰色,如下所示:

I just upgraded some systems to Windows 10 Creators Update and I noticed that the windows forms PropertyGrid control changed its default visual style for headers and bar margins to dark gray, like so:

而且大多数情况下会发生意外的视觉变化,用户并不满意.有没有办法恢复到旧的默认值或覆盖默认样式?

And as mostly happens with unexpected visual changes, users are not happy. Is there a way to revert back to the old default or maybe override the default style?

推荐答案

PropertyGrid 中存在一个错误:

There's a bug in PropertyGrid:

属性 PropertyGrid.LineColor 有一个 DefaultValue 属性设置为 SystemColors.InactiveBorder.
但是内部字段 lineColorSystemColors.ControlDark 初始化.

The property PropertyGrid.LineColor has a DefaultValue attribute Set to SystemColors.InactiveBorder.
But the internal field lineColor is initialized with SystemColors.ControlDark.

这很糟糕,因为 Windows 窗体设计器检测到该属性具有与 DefaultValue 属性相同的值,因此它不会为 PropertyGrid.LineColor<编写设计器代码InitializeComponent 中的/code> 属性.所以在运行时,属性被初始化为 SystemColors.ControlDark.

This is bad, because the Windows Forms designer detects that the property has the same value as the DefaultValue attribute, and therefore it does not write the designer code for the PropertyGrid.LineColor property in InitializeComponent. So at runtime, the property is initialized to SystemColors.ControlDark.

作为一个快速的hack,你可以在InitializeComponent之后设置属性:

As a quick hack, you can set the property after InitializeComponent:

InitializeComponent();
propertyGrid.LineColor = SystemColors.InactiveBorder;

这篇关于Windows 10 创意者更新更改了 PropertyGrid 控件的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆