Winforms无法在设计时设置Property-Values

时间:2016-04-18 12:00:18

标签: c# winforms devexpress xtragrid

Iam尝试基于DevExpress Grid创建自己的GridControl(v.14.2)。这看起来效果很好,但我的设置对象在Designer中不可编辑。

到目前为止,这是我的网格:

    [ToolboxItem(true)]
    [DXToolboxItem(true)]
    public class MyGrid : GridControl
    {
        private Settings _settings;

        public MyGrid()
        {
            _settings= new Settings();
        }

        [Category("My Category")]
        [Description("My Description")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public Settings Settings
        {
            get { return _settings; }
            set { _settings = value; }
        }
}

这是我的设置类:

    [EditorBrowsable(EditorBrowsableState.Always)]
    public class Einstellungen
    {
        [Category("My Category")]
        [Description("My Description")]
        public bool CanGroup { get; set; }

        [Category("My Category")]
        [Description("My Description")]
        public bool IsEditable { get; set; }
}

是否有任何遗失的属性?搜索msdn,但他们也只是推荐使用的属性......

在Designer中我只能看到: 设置| MyNamespace.Settings 但无法编辑bool属性。

1 个答案:

答案 0 :(得分:0)

也许这有效......

[TypeConverter(typeof(ExpandableObjectConverter))]
[EditorBrowsable(EditorBrowsableState.Always)]
public class Einstellungen
{
    [Category("My Category")]
    [Description("My Description")]
    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Advanced)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public bool CanGroup { get; set; }

    [Category("My Category")]
    [Description("My Description")]
    [Browsable(true)]
    [EditorBrowsable(EditorBrowsableState.Advanced)]
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
    public bool IsEditable { get; set; }
}