Conditional “Browsable” Attribute

前端 未结 6 744
梦谈多话
梦谈多话 2020-12-01 17:59


Is there a way to make a \"Browsable\" attribute conditional, so the property that applies it will sometimes appear in the properties page and sometimes not?
thanks

6条回答
  •  隐瞒了意图╮
    2020-12-01 18:52

    You can do this by providing a custom type-model; at the simplest level, you can provide a custom TypeDescriptor for your type derived from ExpandableObjectConverter, and simply include/exclude the given property at whim - but this only works with PropertyGrid - used by the properties page. A more complex approach is to use ICustomTypeDescriptor / TypeDescriptionProvider - this can then work inside things like DataGridView

提交回复
热议问题