2008-09-16 83 views
6

我在我的Asp.net项目中拥有一个具有公共属性的UserControl。当用户突出显示IDE中的UserControl实例时,我不希望此属性显示在Visual Studio属性窗口中。我应该使用什么属性(或其他方法)来防止它出现?将一个UserControl属性设置为在VS属性窗口中不显示

class MyControl : System.Web.UI.UserControl { 
    // Attribute to prevent property from showing in VS Property Window? 
    public bool SampleProperty { get; set; } 

    // other stuff 
} 

回答

11

使用下面的属性...

using System.ComponentModel; 

[Browsable(false)] 
public bool SampleProperty { get; set; } 

在VB.net,这will be

<System.ComponentModel.Browsable(False)> 
3

Tons of attributes在那里控制PropertyGrid中是如何工作的。

[Browsable(false)] 
public bool HiddenProperty {get;set;} 
2

使用System.ComponentModel.Browsable属性

// C# 
    [System.ComponentModel.Browsable(false)] 
相关问题