用户控件自定义结构属性在构建时会丢失值

时间:2017-11-05 11:48:55

标签: c# struct visual-studio-2015 user-controls windows-forms-designer

Corner属性在属性列表中显示正确,该属性实际上未在Form1.Designer.cs文件中更改。下面是定义属性的代码:

private Corner _corner = new Corner(true, true, true, true);

    [Description("Which corners should be rounded"), Category("Look"), Browsable(true)]
    [DefaultValue(typeof(Corner),"True,True,True,False")]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public Corner Corners {
        get { return _corner; }
        set
        {
            if (value == _corner) return;
            _corner = value;
            Invalidate();
        }
    }

这是我的Form1.Designer.cs文件在InitializeComponent方法中创建的代码:

            // 
        this.flatButton1.Location = new System.Drawing.Point(302, 270);
        this.flatButton1.Name = "flatButton1";
        this.flatButton1.Size = new System.Drawing.Size(150, 46);
        this.flatButton1.TabIndex = 5;
        this.flatButton1.Text = "flatButton1";
        // 

0 个答案:

没有答案