Hide some properties in PropertyGrid at run-time

后端 未结 2 1141
悲&欢浪女
悲&欢浪女 2020-12-04 01:56

I am doing a project that allows user to customized the properties of a Control. I have a form that has a control like Label, TextBox,

2条回答
  •  既然无缘
    2020-12-04 02:26

    UPDATE

    Please note this is only useful for Hiding properties (when you can). Reza Aghaei answer is actually the correct answer.

    I'll leave this here as it's suitable for the other case when you just simply want to hide a property when you have access to it.

    Original

    Easiest way is probably to use

    [Browsable(false)]
    

    BrowsableAttribute Class

    Specifies whether a property or event should be displayed in a Properties window.

    [Browsable(false)]
    public int SecretSquirrels
    {
      get; set;
    }
    

    Also as pointed out by Marc Gravell, there is also

    PropertyGrid.BrowsableAttributes Property

    Gets or sets the browsable attributes associated with the object that the property grid is attached to.

提交回复
热议问题