DefaultEventAttribute クラス
アセンブリ: System (system.dll 内)

<AttributeUsageAttribute(AttributeTargets.Class)> _ Public NotInheritable Class DefaultEventAttribute Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class)] public sealed class DefaultEventAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] public ref class DefaultEventAttribute sealed : public Attribute


MyCollection という名前のコレクション クラスを定義する例を次に示します。このクラスは、既定のイベントとして CollectionChanged を指定する DefaultEventAttribute を使用してマークされます。
<DefaultEvent("CollectionChanged")> _ Public Class MyCollection Inherits BaseCollection Public Event CollectionChanged (ByVal sender As Object, _ ByVal e As CollectionChangeEventArgs) ' Insert additional code. End Class 'MyCollection
[DefaultEvent("CollectionChanged")] public class MyCollection : BaseCollection { private CollectionChangeEventHandler onCollectionChanged; public event CollectionChangeEventHandler CollectionChanged { add { onCollectionChanged += value; } remove { onCollectionChanged -= value; } } // Insert additional code. }
[DefaultEvent("CollectionChanged")] public ref class TestCollection: public BaseCollection { private: CollectionChangeEventHandler^ onCollectionChanged; public: event CollectionChangeEventHandler^ CollectionChanged { public: void add(CollectionChangeEventHandler^ eventHandler) { onCollectionChanged += eventHandler; } protected: void remove(CollectionChangeEventHandler^ eventHandler) { onCollectionChanged -= eventHandler; } } // Insert additional code. };
/** @attribute DefaultEvent("CollectionChanged") */ public static class MyCollection extends BaseCollection { private CollectionChangeEventHandler onCollectionChanged; public void add_onCollectionChanged(CollectionChangeEventHandler value) { onCollectionChanged = (CollectionChangeEventHandler) System.Delegate.Combine(onCollectionChanged, value); } public void remove_onCollectionChanged(CollectionChangeEventHandler value) { onCollectionChanged = (CollectionChangeEventHandler) System.Delegate.Remove(onCollectionChanged, value); } // Insert additional code. } //MyCollection
MyCollection のインスタンスを作成する例を次に示します。そのクラスの属性を取得し、DefaultEventAttribute を抽出してから、既定のイベントの名前を出力します。
Public Shared Function Main() As Integer ' Creates a new collection. Dim myNewCollection As New MyCollection() ' Gets the attributes for the collection. Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewCollection) ' Prints the name of the default event by retrieving the ' DefaultEventAttribute from the AttributeCollection. Dim myAttribute As DefaultEventAttribute = _ CType(attributes(GetType(DefaultEventAttribute)), DefaultEventAttribute) Console.WriteLine(("The default event is: " & myAttribute.Name)) Return 0 End Function 'Main
public static int Main() { // Creates a new collection. MyCollection myNewCollection = new MyCollection(); // Gets the attributes for the collection. AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewCollection); /* Prints the name of the default event by retrieving the * DefaultEventAttribute from the AttributeCollection. */ DefaultEventAttribute myAttribute = (DefaultEventAttribute)attributes[typeof(DefaultEventAttribute)]; Console.WriteLine("The default event is: " + myAttribute.Name); return 0; }
int main() { // Creates a new collection. DefaultEventAttributeExample::TestCollection^ newCollection = gcnew DefaultEventAttributeExample::TestCollection; // Gets the attributes for the collection. AttributeCollection^ attributes = TypeDescriptor::GetAttributes(newCollection); // Prints the name of the default event by retrieving the // DefaultEventAttribute from the AttributeCollection. DefaultEventAttribute^ attribute = (DefaultEventAttribute^) attributes[DefaultEventAttribute::typeid]; Console::WriteLine("The default event is: {0}", attribute->Name); }
public static void main(String[] args) { // Creates a new collection. MyCollection myNewCollection = new MyCollection(); // Gets the attributes for the collection. AttributeCollection attributes = TypeDescriptor. GetAttributes(myNewCollection); /* Prints the name of the default event by retrieving the * DefaultEventAttribute from the AttributeCollection. */ DefaultEventAttribute myAttribute = (DefaultEventAttribute)attributes. get_Item(DefaultEventAttribute.class.ToType()); Console.WriteLine("The default event is: " + myAttribute.get_Name()); } //main

System.Attribute
System.ComponentModel.DefaultEventAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DefaultEventAttribute コンストラクタ
アセンブリ: System (system.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DefaultEventAttribute フィールド

名前 | 説明 | |
---|---|---|
![]() | Default | DefaultEventAttribute の既定値 (null 参照 (Visual Basic では Nothing)) を指定します。static フィールドは読み取り専用です。 |

DefaultEventAttribute プロパティ

名前 | 説明 | |
---|---|---|
![]() | Name | この属性が関連付けられているコンポーネントの既定のイベント名を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。 ( Attribute から継承されます。) |

DefaultEventAttribute メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の DefaultEventAttribute と等しいかどうかを示す値を返します。 |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 ( Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 ( Attribute から継承されます。) |
![]() | GetHashCode | オーバーライドされます。 対象のインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 ( Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 ( Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 ( Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

DefaultEventAttribute メンバ
DefaultEventAttribute データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Default | DefaultEventAttribute の既定値 (null 参照 (Visual Basic では Nothing)) を指定します。static フィールドは読み取り専用です。 |

名前 | 説明 | |
---|---|---|
![]() | Name | この属性が関連付けられているコンポーネントの既定のイベント名を取得します。 |
![]() | TypeId | 派生クラスに実装されている場合は、この Attribute の一意の識別子を取得します。(Attribute から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 指定したオブジェクトの値が現在の DefaultEventAttribute と等しいかどうかを示す値を返します。 |
![]() | GetCustomAttribute | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用された指定した型のカスタム属性を取得します。 (Attribute から継承されます。) |
![]() | GetCustomAttributes | オーバーロードされます。 アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されたカスタム属性の配列を取得します。 (Attribute から継承されます。) |
![]() | GetHashCode | オーバーライドされます。 対象のインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDefaultAttribute | 派生クラス内でオーバーライドされたときに、このインスタンスの値が派生クラスの既定値かどうかを示します。 (Attribute から継承されます。) |
![]() | IsDefined | オーバーロードされます。 指定した型のカスタム属性が、アセンブリ、モジュール、型のメンバ、またはメソッド パラメータに適用されているかどうかを判断します。 (Attribute から継承されます。) |
![]() | Match | 派生クラス内でオーバーライドされたときに、指定したオブジェクトとこのインスタンスが等しいかどうかを示す値を返します。 (Attribute から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- DefaultEventAttributeのページへのリンク