Share via


ListViewUpdatedEventArgs.Exception Proprietà

Definizione

Ottiene l'eventuale eccezione generata durante l'operazione di aggiornamento.

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

Valore della proprietà

Exception

Eccezione generata durante l'operazione di aggiornamento oppure null se non è stata generata alcuna eccezione.

Esempio

Nell'esempio seguente viene illustrato come utilizzare la Exception proprietà per determinare se si è verificata un'eccezione durante un'operazione di aggiornamento. Questo esempio di codice fa parte di un esempio più ampio fornito per la ListViewUpdatedEventArgs classe .

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

Commenti

Utilizzare la Exception proprietà per determinare l'eccezione (se presente) generata durante l'operazione di aggiornamento. Se non è stata generata alcuna eccezione, questa proprietà restituisce null.

Nota

Se è stata generata un'eccezione e si gestisce l'eccezione nel gestore eventi, impostare la ExceptionHandled proprietà su true. In caso contrario, il ListView controllo genera nuovamente l'eccezione.

Si applica a

Vedi anche