EditorBrowsableAttribute Classe

Definizione

Specifica che una proprietà o un metodo è visualizzabile in un editor. La classe non può essere ereditata.

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
Ereditarietà
EditorBrowsableAttribute
Attributi

Esempio

Nell'esempio seguente viene illustrato come nascondere una proprietà di una classe da IntelliSense impostando il valore appropriato per l'attributo EditorBrowsableAttribute . Compilare Class1 nel proprio assembly.

In Visual Studio creare una nuova soluzione applicazione Windows e aggiungere un riferimento all'assembly che contiene Class1. Nel costruttore Form1, dichiarare un'istanza di Class1, digitare il nome dell'istanza e premere il tasto punto (.) per attivare l'elenco a discesa IntelliSense dei membri Class1. La proprietà Age non viene visualizzata nell'elenco a discesa.

#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

Commenti

EditorBrowsableAttribute è un hint per una finestra di progettazione che indica se deve essere visualizzata una proprietà o un metodo. È possibile usare questo tipo in una finestra di progettazione visiva o in un editor di testo per determinare cosa è visibile all'utente. Ad esempio, il motore IntelliSense in Visual Studio usa questo attributo per determinare se visualizzare una proprietà o un metodo.

In Visual C#è possibile controllare quando le proprietà avanzate vengono visualizzate in IntelliSense e nella finestra Proprietà con l'impostazione Nascondi membri avanzati in Strumenti | Opzioni | Editor di testo | C#. Il corrispondente EditorBrowsableState è Advanced.

Nota

In Visual C#, EditorBrowsableAttribute non elimina i membri da una classe nello stesso assembly.

Costruttori

EditorBrowsableAttribute()

Consente di inizializzare una nuova istanza della classe EditorBrowsableAttribute con la proprietà State impostata sullo stato predefinito.

EditorBrowsableAttribute(EditorBrowsableState)

Consente di inizializzare una nuova istanza della classe EditorBrowsableAttribute con EditorBrowsableState.

Proprietà

State

Ottiene lo stato esplorabile della proprietà o del metodo.

TypeId

Quando è implementata in una classe derivata, ottiene un identificatore univoco della classe Attribute.

(Ereditato da Attribute)

Metodi

Equals(Object)

Specifica se il valore dell'oggetto specificato è uguale all'oggetto EditorBrowsableAttribute corrente.

GetHashCode()

Restituisce il codice hash per l'istanza.

GetType()

Ottiene l'oggetto Type dell'istanza corrente.

(Ereditato da Object)
IsDefaultAttribute()

In caso di override in una classe derivata, indica se il valore di questa istanza è il valore predefinito per la classe derivata.

(Ereditato da Attribute)
Match(Object)

Quando è sottoposto a override in una classe derivata, restituisce un valore che indica se questa istanza equivale a un oggetto specificato.

(Ereditato da Attribute)
MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Implementazioni dell'interfaccia esplicita

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Esegue il mapping di un set di nomi a un set corrispondente di ID dispatch.

(Ereditato da Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera le informazioni sul tipo relative a un oggetto, che possono essere usate per ottenere informazioni sul tipo relative a un'interfaccia.

(Ereditato da Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Recupera il numero delle interfacce di informazioni sul tipo fornite da un oggetto (0 o 1).

(Ereditato da Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Fornisce l'accesso a proprietà e metodi esposti da un oggetto.

(Ereditato da Attribute)

Si applica a

Vedi anche