Share via


ListViewInsertedEventArgs.ExceptionHandled Propriedade

Definição

Obtém ou define um valor que indica se uma exceção gerada durante a operação de inserção foi tratada no manipulador de eventos.

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

Valor da propriedade

true se a exceção foi tratada no manipulador de eventos; caso contrário, false. O padrão é false.

Exemplos

O exemplo a seguir mostra como usar o ListViewInsertedEventArgs objeto que é passado para o manipulador do 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

Quando uma exceção for gerada durante a operação de inserção, use a ExceptionHandled propriedade para indicar se a exceção foi tratada no manipulador de eventos. Quando essa propriedade é definida truecomo , a exceção é considerada tratada e não é gerada novamente. Se essa propriedade for definida falsecomo , o ListView controle gerará novamente a exceção. Para determinar qual exceção foi gerada, use a Exception propriedade .

Aplica-se a

Confira também