CollectionChangeEventArgs.Element プロパティ

定義

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

public:
 virtual property System::Object ^ Element { System::Object ^ get(); };
public virtual object Element { get; }
public virtual object? Element { get; }
member this.Element : obj
Public Overridable ReadOnly Property Element As Object

プロパティ値

変更されたコレクションのインスタンスを表す Object。コレクションを更新する場合は null

次のコード例では、このメンバーの使用方法を示します。 この例では、イベント ハンドラーがイベントの 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

適用対象

こちらもご覧ください