CollectionChangeEventArgs.Element プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
変更されたコレクションのインスタンスを取得します。
public:
virtual property System::Object ^ Element { System::Object ^ get(); };
public virtual object Element { get; }
member this.Element : obj
Public Overridable ReadOnly Property Element As Object
プロパティ値
変更されたコレクションのインスタンスを表す Object 。コレクションを更新した場合は null 。
例
次のコード例は、このメンバーの使用方法を示しています。 この例では、イベント ハンドラーは、 AutoCompleteStringCollection.CollectionChanged イベントの発生を報告します。 このレポートは、イベントがいつ発生するかを学習するのに役立ち、デバッグに役立ちます。 複数のイベントや頻繁に発生するイベントについて報告するには、 MessageBox.Show を Console.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