ListChangedEventArgs Klasa

Definicja

Udostępnia dane dla zdarzenia ListChanged.

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

Przykłady

W poniższym przykładzie kodu pokazano użycie tego typu. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie BindingSource.ListChanged zdarzenia. Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie, i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub często występujących zdarzeń, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączenie go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu BindingSource o nazwie BindingSource1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem 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

Uwagi

Zdarzenie ListChanged jest zgłaszane, gdy dane w zmianach IBindingList .

Właściwość NewIndex wskazuje indeks elementu, który został dodany, zmieniony lub usunięty. Jeśli element został przeniesiony, NewIndex właściwość wskazuje nową lokalizację elementu, a OldIndex właściwość wskazuje starą lokalizację.

Jeśli zmiana ma wpływ tylko na jeden element, OldIndex wartość właściwości to -1.

Konstruktory

ListChangedEventArgs(ListChangedType, Int32)

Inicjuje nowe wystąpienie ListChangedEventArgs klasy, biorąc pod uwagę typ zmiany i indeks elementu, którego dotyczy problem.

ListChangedEventArgs(ListChangedType, Int32, Int32)

Inicjuje nowe wystąpienie ListChangedEventArgs klasy, biorąc pod uwagę typ zmiany oraz stary i nowy indeks elementu, który został przeniesiony.

ListChangedEventArgs(ListChangedType, Int32, PropertyDescriptor)

Inicjuje nowe wystąpienie ListChangedEventArgs klasy, biorąc pod uwagę typ zmiany, indeks objętego elementu i PropertyDescriptor opisujący element, którego dotyczy problem.

ListChangedEventArgs(ListChangedType, PropertyDescriptor)

Inicjuje ListChangedEventArgs nowe wystąpienie klasy, biorąc pod uwagę typ zmiany i PropertyDescriptor wpływ.

Właściwości

ListChangedType

Pobiera typ zmiany.

NewIndex

Pobiera indeks elementu, którego dotyczy zmiana.

OldIndex

Pobiera stary indeks elementu, który został przeniesiony.

PropertyDescriptor

Pobiera element PropertyDescriptor , który został dodany, zmieniony lub usunięty.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też