Aracılığıyla paylaş


BrowsableAttribute Sınıf

Tanım

Özellikler penceresinde bir özelliğin veya olayın 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.
        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 MyPropertydeğerinin nasıl denetlenecek olduğu BrowsableAttribute gösterilir. İlk olarak, kod nesnesinin 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

bir sınıfı ile BrowsableAttributeiş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 Özellikler penceresinde gözatılabilir özniteliği olmayan veya oluşturucunun BrowsableAttributebrowsable parametresi olarak ayarlanmış trueolarak işaretlenmiş üyeleri görüntüler. Bu üyeler tasarım zamanında değiştirilebilir. Oluşturucunun BrowsableAttributebrowsable parametre kümesiyle false 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.

Uyarı

bir özelliği ile Browsable(true)işaretlediğinizde, bu özniteliğin değeri sabit üyesi 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

Name Description
BrowsableAttribute(Boolean)

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

Alanlar

Name Description
Default

için BrowsableAttributevarsayılan değeri belirtir.Yes 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

Name Description
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

Name Description
Equals(Object)

Bu örneğin ve belirtilen nesnenin eşit olup olmadığını gösterir.

GetHashCode()

Bu örneğin karma kodunu döndürür.

GetType()

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

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

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

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 Objectbasit bir kopyasını oluşturur.

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

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

(Devralındığı yer: Object)

Belirtik Arabirim Kullanımları

Name Description
_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 kullanıma sunulan özelliklere ve yöntemlere erişim sağlar.

(Devralındığı yer: Attribute)

Şunlara uygulanır

Ayrıca bkz.