Share via


ListViewInsertedEventArgs.ExceptionHandled Propiedad

Definición

Obtiene o establece un valor que indica si una excepción que se inició durante la operación de inserción se controló en el controlador 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 de propiedad

Es true si la excepción se ha controlado en el controlador de eventos; en caso contrario, es false. De manera predeterminada, es false.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el ListViewInsertedEventArgs objeto que se pasa al controlador del evento para ItemInserted determinar si se generó una excepción durante la operación de inserción. Este ejemplo de código es parte de un ejemplo más grande proporcionado para la clase 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

Comentarios

Cuando se produce una excepción durante la operación de inserción, use la ExceptionHandled propiedad para indicar si la excepción se controló en el controlador de eventos. Cuando esta propiedad se establece trueen , la excepción se considera controlada y no se vuelve a iniciar. Si esta propiedad se establece en , el ListView control vuelve a falseproducir la excepción. Para determinar qué excepción se generó, use la Exception propiedad .

Se aplica a

Consulte también