ListChangedEventArgs 類別

定義

提供 ListChanged 事件的資料。

public ref class ListChangedEventArgs : EventArgs
public class ListChangedEventArgs : EventArgs
type ListChangedEventArgs = class
    inherit EventArgs
Public Class ListChangedEventArgs
Inherits EventArgs
繼承
ListChangedEventArgs

範例

下列程式碼範例示範此類型的用法。 在此範例中,事件處理常式會報告事件的發生次數 BindingSource.ListChanged 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼入包含名為 BindingSource1 之類型 BindingSource 實例的專案。 然後,確定事件處理常式與 事件相關聯 BindingSource.ListChanged

private void BindingSource1_ListChanged(Object sender, ListChangedEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ListChangedType", e.ListChangedType );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "NewIndex", e.NewIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "OldIndex", e.OldIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "PropertyDescriptor", e.PropertyDescriptor );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ListChanged Event" );
}
Private Sub BindingSource1_ListChanged(sender as Object, e as ListChangedEventArgs) _ 
     Handles BindingSource1.ListChanged

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "ListChangedType", e.ListChangedType)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "NewIndex", e.NewIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "OldIndex", e.OldIndex)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "PropertyDescriptor", e.PropertyDescriptor)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"ListChanged Event")

End Sub

備註

ListChanged當中的資料 IBindingList 變更時,就會引發事件。

屬性 NewIndex 會指出已加入、變更或刪除之專案的索引。 如果移動專案, NewIndex 屬性會指出專案的新位置,而 OldIndex 屬性則表示舊位置。

如果只有一個專案受到變更影響, OldIndex 則屬性值為 -1。

建構函式

ListChangedEventArgs(ListChangedType, Int32)

指定變更類型和受影響項目的索引,初始化 ListChangedEventArgs 類別的新執行個體。

ListChangedEventArgs(ListChangedType, Int32, Int32)

指定變更類型和已移動項目的新舊索引,初始化 ListChangedEventArgs 類別的新執行個體。

ListChangedEventArgs(ListChangedType, Int32, PropertyDescriptor)

指定變更類型、受影響項目的索引和描述受影響項目的 ListChangedEventArgs,初始化 PropertyDescriptor 類別的新執行個體。

ListChangedEventArgs(ListChangedType, PropertyDescriptor)

指定變更類型和受影響的 ListChangedEventArgs,初始化 PropertyDescriptor 類別的新執行個體。

屬性

ListChangedType

取得變更類型。

NewIndex

取得受變更影響之項目的索引。

OldIndex

取得已移動項目的舊索引。

PropertyDescriptor

取得已加入、變更或刪除的 PropertyDescriptor

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱