Compartir a través de


ListViewUpdatedEventArgs.Exception Propiedad

Definición

Obtiene la excepción que se ha iniciado durante la operación de actualización, si la hubiera.

public:
 property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
member this.Exception : Exception
Public ReadOnly Property Exception As Exception

Valor de propiedad

Exception

Excepción que se inició durante la operación de actualización, si la hubiera; si no se inició ninguna excepción, es null.

Ejemplos

En el ejemplo siguiente se muestra cómo usar la Exception propiedad para determinar si se produjo una excepción durante una operación de actualización. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la ListViewUpdatedEventArgs clase .

void ContactsListView_ItemUpdated(Object sender, ListViewUpdatedEventArgs e)
{
    if (e.Exception != null)
    {
        if (e.AffectedRows == 0)
        {
            e.KeepInEditMode = true;
            Message.Text = "An exception occurred updating the contact. " +
                                "Please verify your values and try again.";
        }
        else
            Message.Text = "An exception occurred updating the contact. " +
                                "Please verify the values in the recently updated item.";

        e.ExceptionHandled = true;
    }
}
Sub ContactsListView_ItemUpdated(sender As Object, e As ListViewUpdatedEventArgs)
    If e.Exception IsNot Nothing Then
        If e.AffectedRows = 0 Then
            e.KeepInEditMode = True
            Message.Text = "An exception occurred updating the contact. " & _
                                "Please verify your values and try again."
        Else
            Message.Text = "An exception occurred updating the contact. " & _
                                "Please verify the values in the recently updated item."
        End If

        e.ExceptionHandled = True
    End If
End Sub

Comentarios

Utilice la Exception propiedad para determinar la excepción (si existe) que se generó durante la operación de actualización. Si no se generó ninguna excepción, esta propiedad devuelve null.

Nota

Si se ha generado una excepción y se controla la excepción en el controlador de eventos, establezca la ExceptionHandled propiedad trueen . De lo contrario, el ListView control vuelve a iniciar la excepción.

Se aplica a

Consulte también