[英]Property attribute depending on Windows version
I have a bit strange problem. 我有一个奇怪的问题。
WinForms in Win8 have some bug about Encoding 1252 (confirmed). Win8中的WinForms有一些关于编码1252的错误(已确认)。
I have usercontrol with a public property of Encoding class (user can choose encoding in design-time). 我具有带有Encoding类的公共属性的usercontrol(用户可以在设计时选择编码)。
Currently, I want to hide that property from property grid when user uses my control's dll in Win8 environment. 当前,当用户在Win8环境中使用控件的dll时,我想从属性网格中隐藏该属性。
I want to base on : Operating System Version 我要基于: 操作系统版本
and want to hide property by DesignerVisibility attribute. 并想通过DesignerVisibility属性隐藏属性。
So my question is : How to hide a property when I look for Windows's version by Environment.OSVersion ? 所以我的问题是:当我通过Environment.OSVersion查找Windows版本时,如何隐藏属性?
PS Idea may looks ugly, i can use another classes or anything you can propose, i just need to hide this property in property grid in case of Windows 8 PS Idea看起来很难看,我可以使用其他类或您可以提出的任何建议,在Windows 8的情况下,我只需要将该属性隐藏在属性网格中即可
You could try something like this, before showing the property grid object: 在显示属性网格对象之前,您可以尝试如下操作:
if (IsWindows8()
{
TypeDescriptor.AddAttributes(typeof(Encoding), new BrowsableAttribute(false));
}
propertyGrid1.SelectedObject = myObject;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.