ListViewInsertedEventArgs.Exception Propiedad
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Obtiene la excepción (si existe) que se generó durante la operación de inserción.
public:
property Exception ^ Exception { Exception ^ get(); };
public Exception Exception { get; }
member this.Exception : Exception
Public ReadOnly Property Exception As Exception
Valor de propiedad
Excepción que se generó durante la operación de inserción o null si no se generó ninguna excepción.
Ejemplos
En el ejemplo siguiente se muestra cómo usar el ListViewInsertedEventArgs objeto que se pasa a un controlador para el ItemInserted evento para determinar si se generó una excepción durante la operación de inserción. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la ListViewInsertedEventArgs clase .
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
Si se produjo una excepción y controla la excepción en el controlador de eventos, establezca la ExceptionHandled propiedad trueen . De lo contrario, el ListView control vuelve a iniciar la excepción.