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.Show訊息替換Console.WriteLine為或附加於多行TextBox

要執行範例程式碼,請將其貼到包含一個 BindingSource 名為 BindingSource1的實例的專案中。 然後確保事件處理程式與事件 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。

建構函式

名稱 Description
ListChangedEventArgs(ListChangedType, Int32, Int32)

根據變更類型以及被移動項目的舊索引與新索引,初始化類別的新 ListChangedEventArgs 實例。

ListChangedEventArgs(ListChangedType, Int32, PropertyDescriptor)

初始化類別的新實例 ListChangedEventArgs ,給定變更類型、受影響項目的索引,以及描述受影響項目的 a PropertyDescriptor

ListChangedEventArgs(ListChangedType, Int32)

根據變更類型及受影響項目的索引,初始化該類別的新 ListChangedEventArgs 實例。

ListChangedEventArgs(ListChangedType, PropertyDescriptor)

根據變更類型及受影響的類別ListChangedEventArgs初始化新實例PropertyDescriptor

屬性

名稱 Description
ListChangedType

取得變更的類型。

NewIndex

取得受變更影響之專案的索引。

OldIndex

取得已移動之專案的舊索引。

PropertyDescriptor

取得已新增、變更或刪除的 PropertyDescriptor

方法

名稱 Description
Equals(Object)

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

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

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

(繼承來源 Object)

適用於

另請參閱