ListViewInsertedEventArgs.Exception Propriedade

Definição

Obtém a exceção (se houver) gerada durante a operação de inserção.

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

Valor da propriedade

A exceção gerada durante a operação de inserção ou null se nenhuma exceção foi gerada.

Exemplos

O exemplo a seguir mostra como usar o ListViewInsertedEventArgs objeto que é passado para um manipulador para o ItemInserted evento para determinar se uma exceção foi gerada durante a operação de inserção. Este exemplo de código faz parte de um exemplo maior fornecido para a ListViewInsertedEventArgs classe .

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

Comentários

Se uma exceção tiver sido gerada e você manipular a exceção no manipulador de eventos, defina a ExceptionHandled propriedade como true. Caso contrário, o ListView controle gerará novamente a exceção.

Aplica-se a

Confira também