ListViewInsertedEventArgs.Exception Propriété

Définition

Obtient l'exception (s'il y en a une) qui a été levée pendant l'opération d'insertion.

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

Valeur de propriété

Exception levée lors de l'opération d'insertion, ou null si aucune exception n'a été levée.

Exemples

L’exemple suivant montre comment utiliser l’objet ListViewInsertedEventArgs passé à un gestionnaire pour l’événement ItemInserted afin de déterminer si une exception a été levée pendant l’opération d’insertion. Cet exemple de code fait partie d’un exemple plus grand fourni pour la 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

Remarques

Si une exception a été levée et que vous gérez l’exception dans le gestionnaire d’événements, définissez la propriété sur ExceptionHandledtrue. Sinon, le ListView contrôle lève de nouveau l’exception.

S’applique à

Voir aussi