DefaultEventAttributeとは? わかりやすく解説

DefaultEventAttribute クラス

コンポーネント既定イベント指定します

名前空間: System.ComponentModel
アセンブリ: System (system.dll 内)
構文構文

<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class
 DefaultEventAttribute
    Inherits Attribute
Dim instance As DefaultEventAttribute
[AttributeUsageAttribute(AttributeTargets.Class)] 
public sealed class DefaultEventAttribute :
 Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] 
public ref class DefaultEventAttribute sealed
 : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public final class DefaultEventAttribute extends
 Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public final class DefaultEventAttribute extends
 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.Object
   System.Attribute
    System.ComponentModel.DefaultEventAttribute
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

DefaultEventAttribute コンストラクタ


DefaultEventAttribute フィールド


DefaultEventAttribute プロパティ


DefaultEventAttribute メソッド


パブリック メソッドパブリック メソッド

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

関連項目

DefaultEventAttribute クラス
System.ComponentModel 名前空間
Attribute

DefaultEventAttribute メンバ

コンポーネント既定イベント指定します

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


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

関連項目

DefaultEventAttribute クラス
System.ComponentModel 名前空間
Attribute



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DefaultEventAttribute」の関連用語

DefaultEventAttributeのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DefaultEventAttributeのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS