ListViewUpdatedEventArgs.ExceptionHandled 屬性

定義

取得或設定值,指出是否在事件期間處理更新作業中引發的例外狀況。

public:
 property bool ExceptionHandled { bool get(); void set(bool value); };
public bool ExceptionHandled { get; set; }
member this.ExceptionHandled : bool with get, set
Public Property ExceptionHandled As Boolean

屬性值

如果例外狀況在事件處理常式中已經過處理,則為 true,否則為 false。 預設為 false

範例

下列範例示範如何使用 ExceptionHandled 屬性來指出事件處理常式中已處理例外狀況。 此程式碼範例是針對 類別提供的較大範例的 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

備註

如果在更新作業期間引發例外狀況,請使用 ExceptionHandled 屬性來指出您是否已在事件期間處理例外狀況。 如果此屬性設定 true 為 ,則會將例外狀況視為已處理,而且控制項不會重新擲回 ListView 。 如果此屬性設定為 false ,則 ListView 控制項會重新擲回例外狀況。 若要判斷引發的例外狀況,請使用 Exception 屬性。

適用於

另請參閱