ListViewInsertedEventArgs.Exception プロパティ

定義

挿入操作中に例外が発生した場合は、その例外を取得します。

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

プロパティ値

挿入操作中に発生した例外。例外が発生しなかった場合は null

次の例は、イベントの 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

注釈

例外が発生し、イベント ハンドラーで例外を処理する場合は、 プロパティを ExceptionHandledtrue設定します。 それ以外の場合、コントロールは ListView 例外を再スローします。

適用対象

こちらもご覧ください