CollectionChangeEventArgs クラス

定義

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

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

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

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

適用対象

こちらもご覧ください