ListChangedEventArgs.NewIndex Свойство

Определение

Возвращает индекс элемента, затрагиваемого изменением.

public:
 property int NewIndex { int get(); };
public int NewIndex { get; }
member this.NewIndex : int
Public ReadOnly Property NewIndex As Integer

Значение свойства

Индекс элемента, затрагиваемого изменением.

Примеры

В следующем примере кода показано использование этого элемента. В этом примере обработчик событий сообщает о возникновении BindingSource.ListChanged события. Этот отчет поможет вам узнать, когда происходит событие, и может помочь в отладке. Чтобы сообщить о нескольких событиях или о событиях, которые происходят часто, рекомендуется заменить MessageBox.ShowConsole.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

Комментарии

Для перемещенных элементов это свойство представляет новое расположение элемента.

Применяется к

См. также раздел