ListChangedEventArgs.NewIndex Propriedade

Definição

Obtém o índice do item afetado pela alteração.Gets the index of the item affected by the change.

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

Valor da propriedade

Int32

O índice dos afetados pela alteração.The index of the affected by the change.

Exemplos

O exemplo de código a seguir demonstra o uso desse membro.The following code example demonstrates the use of this member. No exemplo, um manipulador de eventos relata a ocorrência do BindingSource.ListChanged evento.In the example, an event handler reports on the occurrence of the BindingSource.ListChanged event. Este relatório ajuda você a aprender quando o evento ocorre e pode ajudá-lo na depuração.This report helps you to learn when the event occurs and can assist you in debugging. Para relatar vários eventos ou eventos que ocorrem com frequência, considere substituir MessageBox.Show Console.WriteLine ou anexar a mensagem a uma multilinha TextBox .To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

Para executar o código de exemplo, Cole-o em um projeto que contém uma instância do tipo BindingSource chamado BindingSource1 .To run the example code, paste it into a project that contains an instance of type BindingSource named BindingSource1. Em seguida, verifique se o manipulador de eventos está associado ao BindingSource.ListChanged evento.Then ensure that the event handler is associated with the BindingSource.ListChanged event.

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

Comentários

Para itens que foram movidos, essa propriedade representa o novo local do item.For items that have been moved, this property represents the new location of the item.

Aplica-se a

Confira também