DefaultPropertyAttribute Sınıf
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Bir bileşen için varsayılan özelliği belirtir.
public ref class DefaultPropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class)]
public sealed class DefaultPropertyAttribute : Attribute
public sealed class DefaultPropertyAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class)>]
type DefaultPropertyAttribute = class
inherit Attribute
type DefaultPropertyAttribute = class
inherit Attribute
Public NotInheritable Class DefaultPropertyAttribute
Inherits Attribute
- Devralma
- Öznitelikler
Örnekler
Aşağıdaki örnek adlı MyControlbir denetimi tanımlar. sınıfı, varsayılan özellik olarak belirten bir DefaultPropertyAttribute ile işaretlenir MyProperty .
[DefaultProperty("MyProperty")]
ref class MyControl: public Control
{
public:
property int MyProperty
{
int get()
{
// Insert code here.
return 0;
}
void set( int value )
{
// Insert code here.
}
}
// Insert any additional code.
};
[DefaultProperty("MyProperty")]
public class MyControl : Control
{
public int MyProperty
{
get =>
// Insert code here.
0;
set
{
// Insert code here.
}
}
// Insert any additional code.
}
<DefaultProperty("MyProperty")> _
Public Class MyControl
Inherits Control
Public Property MyProperty() As Integer
Get
' Insert code here.
Return 0
End Get
Set
' Insert code here.
End Set
End Property
' Insert any additional code.
End Class
Sonraki örnek, örneğini MyControloluşturur. Ardından sınıfın özniteliklerini alır, ayıklar DefaultPropertyAttributeve varsayılan özelliğin adını yazdırır.
int main()
{
// Creates a new control.
Form1::MyControl^ myNewControl = gcnew Form1::MyControl;
// Gets the attributes for the collection.
AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewControl );
/* Prints the name of the default property by retrieving the
* DefaultPropertyAttribute from the AttributeCollection. */
DefaultPropertyAttribute^ myAttribute = dynamic_cast<DefaultPropertyAttribute^>(attributes[ DefaultPropertyAttribute::typeid ]);
Console::WriteLine( "The default property is: {0}", myAttribute->Name );
return 0;
}
public static int Main()
{
// Creates a new control.
MyControl myNewControl = new();
// Gets the attributes for the collection.
AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewControl);
/* Prints the name of the default property by retrieving the
* DefaultPropertyAttribute from the AttributeCollection. */
DefaultPropertyAttribute myAttribute =
(DefaultPropertyAttribute)attributes[typeof(DefaultPropertyAttribute)];
Console.WriteLine("The default property is: " + myAttribute.Name);
return 0;
}
Public Shared Function Main() As Integer
' Creates a new control.
Dim myNewControl As New MyControl()
' Gets the attributes for the collection.
Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewControl)
' Prints the name of the default property by retrieving the
' DefaultPropertyAttribute from the AttributeCollection.
Dim myAttribute As DefaultPropertyAttribute = _
CType(attributes(GetType(DefaultPropertyAttribute)), DefaultPropertyAttribute)
Console.WriteLine(("The default property is: " + myAttribute.Name))
Return 0
End Function 'Main
Açıklamalar
Name Varsayılan özelliğin adını almak için özelliğini kullanın.
Daha fazla bilgi için bkz . Öznitelikler.
Oluşturucular
| Name | Description |
|---|---|
| DefaultPropertyAttribute(String) |
DefaultPropertyAttribute sınıfının yeni bir örneğini başlatır. |
Alanlar
| Name | Description |
|---|---|
| Default |
için DefaultPropertyAttributevarsayılan değeri belirtir. |
Özellikler
| Name | Description |
|---|---|
| Name |
Bu özniteliğin bağlı olduğu bileşen için varsayılan özelliğin adını 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) |
Verilen nesnenin değerinin geçerli DefaultPropertyAttributedeğerine eşit olup olmadığını döndürür. |
| GetHashCode() |
Bu örneğin karma kodunu döndürür. |
| GetType() |
Geçerli örneğin Type alır. (Devralındığı yer: Object) |
| 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 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) |