ListViewUpdatedEventArgs.Exception 属性     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取更新操作过程中引发的异常(如果有)。
public:
 property Exception ^ Exception { Exception ^ get(); };public Exception Exception { get; }member this.Exception : ExceptionPublic ReadOnly Property Exception As 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 会重新引发异常。