ListViewUpdatedEventArgs.Exception Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈