ListChangedEventArgs 类   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供 ListChanged 事件的数据。
public ref class ListChangedEventArgs : EventArgspublic class ListChangedEventArgs : EventArgstype ListChangedEventArgs = class
    inherit EventArgsPublic Class ListChangedEventArgs
Inherits EventArgs- 继承
示例
下面的代码示例演示了此类型的用法。 在此示例中,事件处理程序报告 BindingSource.ListChanged 事件的发生情况。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑将 MessageBox.Show 替换为 Console.WriteLine 或将消息追加到多行 TextBox。
若要运行示例代码,请将它粘贴到包含名为 BindingSource1BindingSource 类型的实例的项目。 然后,确保事件处理程序与 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
注解
当 IBindingList 中的数据发生更改时,将引发 ListChanged 事件。
NewIndex 属性指示已添加、更改或删除的项的索引。 如果移动了项,则 NewIndex 属性指示该项的新位置,OldIndex 属性指示旧位置。
如果只有一项受更改影响,则 OldIndex 属性值为 -1。
构造函数
| ListChangedEventArgs(ListChangedType, Int32, Int32) | 在给定更改类型和已移动项的旧索引的情况下,初始化 ListChangedEventArgs 类的新实例。 | 
| ListChangedEventArgs(ListChangedType, Int32, PropertyDescriptor) | 在给定更改类型、受影响项的索引以及描述受影响项的 PropertyDescriptor 的情况下,初始化 ListChangedEventArgs 类的新实例。 | 
| ListChangedEventArgs(ListChangedType, Int32) | 在给定更改类型和受影响项的索引的情况下,初始化 ListChangedEventArgs 类的新实例。 | 
| ListChangedEventArgs(ListChangedType, PropertyDescriptor) | 在给定更改类型和受影响的 PropertyDescriptor 的情况下初始化 ListChangedEventArgs 类的新实例。 | 
属性
| ListChangedType | 获取更改的类型。 | 
| NewIndex | 获取受更改影响的项的索引。 | 
| OldIndex | 获取已移动的项的旧索引。 | 
| PropertyDescriptor | 获取已添加、更改或删除的 PropertyDescriptor。 | 
方法
| Equals(Object) | 确定指定的对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 用作默认哈希函数。(继承自 Object) | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object的浅表副本。(继承自 Object) | 
| ToString() | 返回一个表示当前对象的字符串。(继承自 Object) |