简体   繁体   English

如何在c#中将defaulty的默认值设置为propertyygrid的大小类型属性?

[英]How can I set default value to size type property of propertyygrid in c#?

I have a propertygrid that myclass is objectsource of it. 我有一个属性网格,myclass是它的对象源。 In my class I define one item from Size type. 在我的班级中,我从大小类型中定义了一个项目。 How can I set default value in item attribute ? 如何在item属性中设置默认值?

Please see my code : 请看我的代码:

[CategoryAttribute("Information"), DefaultValue(Size(0, 0))]
public Size AndaazehPixel { get; set; }

my error : 'System.Drawing.Size' is a 'type' but is used like a 'variable' 我的错误:'System.Drawing.Size'是'type'但是像'变量'一样使用

Try it like this: 试试这样:

[DefaultValue(typeof(Size), "0, 0")]
public Size AndaazehPixel { get; set; }

暂无
暂无

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

相关问题 如何在 C# 中将属性设置为默认值? - How do I set a property to a default value in C#? 如何在C#中使用反射从类型和设置属性值中按名称获取属性 - How can I Get the property by name from type and Set Propert value using reflection in C# 我可以在ac#class中设置一个属性,以便始终具有特定的默认值吗? - Can I set a property in a c# class to always have a specific default value? C#:如何为部分类中的属性设置默认值? - C#: How to set default value for a property in a partial class? 如何为从dependencyobject派生的类型的依赖属性设置默认值 - How can i set a default value for a dependency property of type derived from dependencyobject 从字符串映射到int类型属性时,如何在automapper中将默认值设置为异常? - How can I set default value to exceptions in automapper while mapping from string to int type property? 如何在 C# 中将 Button 的类型设置为“Button”(而不是默认的“Submit”)? - How can I set a Button's type to "Button" (as opposed to the default "Submit") in C#? C#:如何从派生类设置属性的最大值? (而不是在基类中) - C#: How can I set a maximal Value of a property from a derived class? (And not in base class) 如何将默认参数值设置为BigInteger类型? - How can I set default parameter value to BigInteger type? 如何设置最小控制台大小 C#? - How can I set a minimum console size C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM