Επεξεργασία

Κοινή χρήση μέσω


ListViewUpdatedEventArgs.Exception Property

Definition

Gets the exception, if any, that was raised during the update operation.

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

Property Value

The exception that was raised during the update operation, if any; if no exception was raised, null.

Examples

The following example shows how to use the Exception property to determine whether an exception occurred during an update operation. This code example is part of a larger example provided for the ListViewUpdatedEventArgs class.

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

Remarks

Use the Exception property to determine the exception (if any) that was raised during the update operation. If no exception was raised, this property returns null.

Note

If an exception was raised and you handle the exception in the event handler, set the ExceptionHandled property to true. Otherwise, the ListView control re-throws the exception.

Applies to

See also