CollectionChangeEventArgs クラス

定義

CollectionChanged イベントのデータを提供します。

public ref class CollectionChangeEventArgs : EventArgs
public class CollectionChangeEventArgs : EventArgs
type CollectionChangeEventArgs = class
    inherit EventArgs
Public Class CollectionChangeEventArgs
Inherits EventArgs
継承
CollectionChangeEventArgs

次のコード例では、この型の使用方法を示します。 この例では、イベント ハンドラーは、 AutoCompleteStringCollection.CollectionChanged イベントの発生を報告します。 このレポートは、イベントがいつ発生するかを学習するのに役立ち、デバッグに役立ちます。 複数のイベントや頻繁に発生するイベントについて報告するには、 MessageBox.ShowConsole.WriteLine に置き換えるか、メッセージを複数行の TextBoxに追加することを検討してください。

コード例を実行するには、AutoCompleteStringCollectionという名前の型のインスタンスを含むプロジェクトAutoCompleteStringCollection1貼り付けます。 次に、イベント ハンドラーが AutoCompleteStringCollection.CollectionChanged イベントに関連付けられていることを確認します。

private void AutoCompleteStringCollection1_CollectionChanged(Object sender, CollectionChangeEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Element", e.Element );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CollectionChanged Event" );
}
Private Sub AutoCompleteStringCollection1_CollectionChanged(sender as Object, e as CollectionChangeEventArgs) _ 
     Handles AutoCompleteStringCollection1.CollectionChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Action", e.Action)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Element", e.Element)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"CollectionChanged Event")

End Sub

注釈

CollectionChanged イベントは、コレクションに要素を追加したり、コレクションから要素を削除したりするなどして、コレクション内の項目を変更すると発生します。 このイベントは、個々の要素がその値を変更したときに発生しません。

コンストラクター

名前 説明
CollectionChangeEventArgs(CollectionChangeAction, Object)

CollectionChangeEventArgs クラスの新しいインスタンスを初期化します。

プロパティ

名前 説明
Action

コレクションの変更方法を指定するアクションを取得します。

Element

変更されたコレクションのインスタンスを取得します。

メソッド

名前 説明
Equals(Object)

指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Objectの簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください