BrowsableAttribute Sınıf

Tanım

Bir özelliğin veya olayın bir Özellikler penceresi görüntülenip görüntülenmeyeceğini belirtir.

public ref class BrowsableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.All)]
public sealed class BrowsableAttribute : Attribute
public sealed class BrowsableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.All)>]
type BrowsableAttribute = class
    inherit Attribute
type BrowsableAttribute = class
    inherit Attribute
Public NotInheritable Class BrowsableAttribute
Inherits Attribute
Devralma
BrowsableAttribute
Öznitelikler

Örnekler

Aşağıdaki örnek bir özelliği göz atılabilir olarak işaretler.

public:
   [Browsable(true)]
   property int MyProperty 
   {
      int get()
      {
         // Insert code here.
         return 0;
      }
      void set( int value )
      {
         // Insert code here.
      }
   }
[Browsable(true)]
public int MyProperty
{
    get
    {
        // Insert code here.
        return 0;
    }
    set
    {
        // Insert code here.
    }
}

<Browsable(True)> _
Public Property MyProperty() As Integer
    Get
        ' Insert code here.
        Return 0
    End Get
    Set
        ' Insert code here.
    End Set 
End Property

Sonraki örnekte için değerinin nasıl denetlenecekleri gösterilmektedir BrowsableAttributeMyProperty. İlk olarak kod, nesnenin tüm özellikleriyle bir PropertyDescriptorCollection alır. Ardından kod, almak için dizinini PropertyDescriptorCollection oluşturur MyProperty. Ardından bu özelliğin özniteliklerini döndürür ve öznitelikler değişkenine kaydeder.

Örnek, değerini BrowsableAttributedenetlemenin iki farklı yolunu sunar. İkinci kod parçasında örnek yöntemini çağırır Equals . Son kod parçasında örnek, değerini denetlemek için özelliğini kullanır Browsable .

// Gets the attributes for the property.
AttributeCollection^ attributes = TypeDescriptor::GetProperties( this )[ "MyProperty" ]->Attributes;

// Checks to see if the value of the BrowsableAttribute is Yes.
if ( attributes[ BrowsableAttribute::typeid ]->Equals( BrowsableAttribute::Yes ) )
{
   
   // Insert code here.
}

// This is another way to see whether the property is browsable.
BrowsableAttribute^ myAttribute = dynamic_cast<BrowsableAttribute^>(attributes[ BrowsableAttribute::typeid ]);
if ( myAttribute->Browsable )
{
   // Insert code here.
}
// Gets the attributes for the property.
AttributeCollection attributes =
   TypeDescriptor.GetProperties(this)["MyProperty"].Attributes;

// Checks to see if the value of the BrowsableAttribute is Yes.
if (attributes[typeof(BrowsableAttribute)].Equals(BrowsableAttribute.Yes))
{
    // Insert code here.
}

// This is another way to see whether the property is browsable.
BrowsableAttribute myAttribute =
   (BrowsableAttribute)attributes[typeof(BrowsableAttribute)];
if (myAttribute.Browsable)
{
    // Insert code here.
}
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _
    TypeDescriptor.GetProperties(Me)("MyProperty").Attributes

' Checks to see if the value of the BrowsableAttribute is Yes.
If attributes(GetType(BrowsableAttribute)).Equals(BrowsableAttribute.Yes) Then
    ' Insert code here.
End If 

' This is another way to see whether the property is browsable.
Dim myAttribute As BrowsableAttribute = _
    CType(attributes(GetType(BrowsableAttribute)), BrowsableAttribute)
If myAttribute.Browsable Then
    ' Insert code here.
End If

ile BrowsableAttributebir sınıfı işaretlediyseniz, değerini denetlemek için aşağıdaki kodu kullanın.

AttributeCollection^ attributes = TypeDescriptor::GetAttributes( MyProperty );
if ( attributes[ BrowsableAttribute::typeid ]->Equals( BrowsableAttribute::Yes ) )
{
   // Insert code here.
}
AttributeCollection attributes =
    TypeDescriptor.GetAttributes(MyProperty);
if (attributes[typeof(BrowsableAttribute)].Equals(BrowsableAttribute.Yes))
{
    // Insert code here.
}
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(MyProperty)
If attributes(GetType(BrowsableAttribute)).Equals(BrowsableAttribute.Yes) Then
    ' Insert code here.
End If

Açıklamalar

Görsel tasarımcı genellikle gözatılabilir özniteliği olmayan veya oluşturucunun BrowsableAttributebrowsable parametresi olarak ayarlanmış trueolarak işaretlenmiş üyelerin Özellikler penceresi görüntülenir. Bu üyeler tasarım zamanında değiştirilebilir. Oluşturucunun BrowsableAttributebrowsable parametresi ayarlı false olarak işaretlenen üyeler tasarım zamanı düzenleme için uygun değildir ve bu nedenle görsel tasarımcıda görüntülenmez. Varsayılan değer: true.

Not

bir özelliği ile Browsable(true)işaretlediğinizde, bu özniteliğin değeri sabit üye Yesolarak ayarlanır. ile Browsable(false)işaretlenmiş bir özellik için değeridir No. Bu nedenle, kodunuzda bu özniteliğin değerini denetlediğinizde özniteliğini veya BrowsableAttribute.Noolarak BrowsableAttribute.Yes belirtmeniz gerekir.

Daha fazla bilgi için bkz . Öznitelikler.

Oluşturucular

BrowsableAttribute(Boolean)

BrowsableAttribute sınıfının yeni bir örneğini başlatır.

Alanlar

Default

için BrowsableAttributeYesvarsayılan değerini belirtir. Bu static alan salt okunur.

No

Bir özelliğin veya olayın tasarım zamanında değiştirilemeyeceğini belirtir. Bu static alan salt okunur.

Yes

Bir özelliğin veya olayın tasarım zamanında değiştirilebileceğini belirtir. Bu static alan salt okunur.

Özellikler

Browsable

Bir nesnenin gözatılabilir olup olmadığını belirten bir değer alır.

TypeId

Türetilmiş bir sınıfta uygulandığında, bu Attributeiçin benzersiz bir tanımlayıcı alır.

(Devralındığı yer: Attribute)

Yöntemler

Equals(Object)

Bu örnek ile belirtilen bir nesnenin eşit olup olmadığını gösterir.

GetHashCode()

Bu örneğe ilişkin karma kodu döndürür.

GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
IsDefaultAttribute()

Bu özniteliğin varsayılan olup olmadığını belirler.

IsDefaultAttribute()

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin değerinin türetilmiş sınıf için varsayılan değer olup olmadığını gösterir.

(Devralındığı yer: Attribute)
Match(Object)

Türetilmiş bir sınıfta geçersiz kılındığında, bu örneğin belirtilen bir nesneye eşit olup olmadığını gösteren bir değer döndürür.

(Devralındığı yer: Attribute)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

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

Bir ad kümesini karşılık gelen bir dağıtma tanımlayıcısı kümesine eşler.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Bir arabirimin tür bilgilerini almak için kullanılabilecek bir nesnenin tür bilgilerini alır.

(Devralındığı yer: Attribute)
_Attribute.GetTypeInfoCount(UInt32)

Bir nesnenin sağladığı tür bilgisi arabirimlerinin sayısını alır (0 ya da 1).

(Devralındığı yer: Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Bir nesne tarafından sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.