EditorBrowsableAttribute 类

指定某个属性或方法在编辑器中可以查看。无法继承此类。

**命名空间:**System.ComponentModel
**程序集:**System(在 system.dll 中)

语法

声明
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Enum Or AttributeTargets.Constructor Or AttributeTargets.Method Or AttributeTargets.Property Or AttributeTargets.Field Or AttributeTargets.Event Or AttributeTargets.Interface Or AttributeTargets.Delegate)> _
Public NotInheritable Class EditorBrowsableAttribute
    Inherits Attribute
用法
Dim instance As EditorBrowsableAttribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate)] 
public sealed class EditorBrowsableAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Enum|AttributeTargets::Constructor|AttributeTargets::Method|AttributeTargets::Property|AttributeTargets::Field|AttributeTargets::Event|AttributeTargets::Interface|AttributeTargets::Delegate)] 
public ref class EditorBrowsableAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate) */ 
public final class EditorBrowsableAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Enum|AttributeTargets.Constructor|AttributeTargets.Method|AttributeTargets.Property|AttributeTargets.Field|AttributeTargets.Event|AttributeTargets.Interface|AttributeTargets.Delegate) 
public final class EditorBrowsableAttribute extends Attribute

备注

您可以在可视化设计器或文本编辑器中使用该类来确定用户可见的内容。例如,Visual Studio 中的“IntelliSense”引擎使用此属性来确定是否显示方法或属性。

示例

下面的示例说明如何通过为 EditorBrowsableAttribute 属性 (Attribute) 设置适当的值来向 IntelliSense 隐藏控件的属性 (Property)。在打开新应用程序,添加对控件的引用,并声明该控件的实例之后,IntelliSense 不在下拉列表框中显示 Age 属性。

Private ageval As Integer

<EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)> _
Public Property Age() As Integer
    Get
        Return ageval
    End Get
    Set(ByVal Value As Integer)
        If Not ageval.Equals(Value) Then
            ageval = Value
        End If
    End Set
End Property
int ageval;
[EditorBrowsable(EditorBrowsableState.Never)]
public int Age
{ 
    get { return ageval; }
    set 
    {
        if (!ageval.Equals(value)) 
        {
            ageval = value;
        }
    }
}
private:
   int ageval;

public:
   [EditorBrowsable(EditorBrowsableState::Never)]
   property int Age 
   {
      int get()
      {
         return ageval;
      }
      void set( int value )
      {
         if ( ageval != value )
         {
            ageval = value;
         }
      }
   }
private int ageVal;

/** @attribute EditorBrowsable(EditorBrowsableState.Never)
 */
/** @property
 */
public int get_Age()
{
    return ageVal;
}//get_Age

/** @property 
 */
public void set_Age(int value)
{
    if (ageVal != value) {
        ageVal = value;
    }
}//set_Age

继承层次结构

System.Object
   System.Attribute
    System.ComponentModel.EditorBrowsableAttribute

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

EditorBrowsableAttribute 成员
System.ComponentModel 命名空间
EditorBrowsableState