Search code examples
c#propertygrid

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


I have a propertygrid that myclass is objectsource of it. In my class I define one item from Size type. How can I set default value in item attribute ?

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'


Solution

  • Try it like this:

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