ListViewUpdatedEventArgs.Exception 属性

定义

获取更新操作过程中引发的异常(如果有)。

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

属性值

Exception

更新操作过程中引发的异常(如果有);如果未引发任何异常,则为 null

示例

以下示例演示如何使用 Exception 属性来确定更新操作期间是否发生异常。 此代码示例是为类提供的大型示例的 ListViewUpdatedEventArgs 一部分。

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

注解

Exception使用属性确定在更新操作期间引发的任何) (异常。 如果未引发异常,则此属性返回 null

备注

如果引发异常并且处理事件处理程序中的异常,请将 ExceptionHandled 该属性设置为 true。 否则,控件 ListView 将重新引发异常。

适用于

另请参阅