PropertyGrid.BrowsableAttributes自定义显示

PropertyGrid.BrowsableAttributes是用来设置显示的属性

当不使用BrowsableAttribute标记属性,而是自定义标记属性时,需要实现自定义

    public class Graphic2DEntityEditorBrowsableAttribute:Attribute
    {
        private bool _Browsable = true;
        public bool Browsable
        {
            get
            {
                return _Browsable;
            }
            set
            {
                _Browsable=value;
            }
        }
        public Graphic2DEntityEditorBrowsableAttribute()
        {

        }
        public Graphic2DEntityEditorBrowsableAttribute(bool browsable)
        {
            _Browsable = browsable;
        }
    }

使用方式:

propertyGrid1.BrowsableAttributes = new AttributeCollection(new Attribute[] { new Graphic2DEntityEditorBrowsableAttribute() });



propertyGrid1.BrowsableAttributes = new AttributeCollection(new Attribute[] { new Graphic2DEntityEditorBrowsableAttribute() });


版权声明:本文为ares1986原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。