EditorBrowsableAttribute クラス

定義

クラスまたはメンバーがエディターで表示可能であることを指定します。 このクラスは継承できません。

public ref class EditorBrowsableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct)]
public sealed class EditorBrowsableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Constructor | System.AttributeTargets.Delegate | System.AttributeTargets.Enum | System.AttributeTargets.Event | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.Struct)>]
type EditorBrowsableAttribute = class
    inherit Attribute
Public NotInheritable Class EditorBrowsableAttribute
Inherits Attribute
継承
EditorBrowsableAttribute
属性

次の例では、 EditorBrowsableAttribute 属性の適切な値を設定して、IntelliSense からクラスのプロパティを非表示にする方法を示します。

独自のアセンブリで Class1 をビルドします。 次に、Visual Studioで新しいプロジェクトを作成し、Class1を含むアセンブリへの参照を追加します。 Class1のインスタンスを宣言し、インスタンスの名前を入力し、. キーを押して、Class1メンバーの IntelliSense リストをアクティブにします。 Age プロパティは非表示であるため、ドロップダウン リストには表示されません。

#using <system.dll>

using namespace System;
using namespace System::ComponentModel;

namespace EditorBrowsableDemo
{
   public ref class Class1
   {
   public:
      Class1()
      { 
         //
         // TODO: Add constructor logic here
         //
      }

   private:
      int ageval;

   public:
      [EditorBrowsable(EditorBrowsableState::Never)]
      property int Age 
      {
         int get()
         {
            return ageval;
         }

         void set( int value )
         {
            if ( ageval != value )
            {
               ageval = value;
            }
         }
      }
   };
}
using System.ComponentModel;

namespace EditorBrowsableDemo;

public class Class1
{
    public Class1() { }

    [EditorBrowsable(EditorBrowsableState.Never)]
    public int Age
    {
        get; set;
    }

    public int Height
    {
        get; set;
    }
}
Imports System.ComponentModel

Public Class Class1

    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

End Class

注釈

EditorBrowsableAttribute は、クラスまたはメンバーを表示するかどうかを示すデザイナーへのヒントです。 ビジュアル デザイナーまたはテキスト エディターでこの型を使用して、ユーザーに表示する内容を決定できます。 たとえば、Visual Studioの IntelliSense エンジンでは、この属性を使用して、クラスまたはメンバーを表示するかどうかを決定します。

Visual Studioでは、 Tools Options Text Editor < C# の下の Hide Advanced Members 設定を使用して、C# IntelliSense とプロパティ ウィンドウに詳細プロパティを表示するタイミングを制御できます。 対応する EditorBrowsableStateAdvanced

Note

C# では、 EditorBrowsableAttribute はメンバーが同じアセンブリ内のクラスによって参照されることを抑制しません。

コンストラクター

名前 説明
EditorBrowsableAttribute()

EditorBrowsableAttributeが既定の状態に設定されたState クラスの新しいインスタンスを初期化します。

EditorBrowsableAttribute(EditorBrowsableState)

EditorBrowsableAttributeを使用して、EditorBrowsableState クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明