共用方式為


ListViewInsertedEventArgs.ExceptionHandled 屬性

定義

取得或設定 a,表示插入操作中提出的例外是否已在事件處理程序中被處理。

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

範例

以下範例說明如何利用 ListViewInsertedEventArgs 傳遞給事件處理 ItemInserted 程序的物件來判斷插入操作中是否觸發了異常。 此程式碼範例是本類別更大範例 ListViewInsertedEventArgs 的一部分。

void ContactsListView_ItemInserted(Object sender, ListViewInsertedEventArgs e)
{
  if (e.Exception != null)
  {
    if (e.AffectedRows == 0)
    {
      e.KeepInInsertMode = true;
      Message.Text = "An exception occurred inserting the new Contact. " +
        "Please verify your values and try again.";
    }
    else
      Message.Text = "An exception occurred inserting the new Contact. " +
        "Please verify the values in the newly inserted item.";

    e.ExceptionHandled = true;
  }
}
Sub ContactsListView_ItemInserted(ByVal sender As Object, ByVal e As ListViewInsertedEventArgs)

  If e.Exception IsNot Nothing Then

    If e.AffectedRows = 0 Then
      e.KeepInInsertMode = True
      Message.Text = "An exception occurred inserting the new Contact. " & _
        "Please verify your values and try again."
    Else
      Message.Text = "An exception occurred inserting the new Contact. " & _
        "Please verify the values in the newly inserted item."
    End If

    e.ExceptionHandled = True
  End If
End Sub

備註

當插入操作中異常發生時,使用該 ExceptionHandled 屬性指示該異常是否在事件處理程序中被處理。 當此屬性被設定為 true時,該例外被視為已處理,且不會被重新拋出。 若此屬性設為 false,控制 ListView 項會重新拋出例外。 要判斷提出的是哪個例外,請使用該 Exception 屬性。

適用於

另請參閱