Поделиться через


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

Комментарии

Если возникло исключение и вы обрабатываете исключение в обработчике событий, задайте ExceptionHandled для свойства значение true. ListView В противном случае элемент управления повторно создает исключение.

Применяется к

См. также раздел