ListViewInsertedEventArgs.Exception Proprietà

Definizione

Ottiene l'eventuale eccezione generata durante l'operazione di inserimento.

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

Valore della proprietà

Eccezione generata durante l'operazione di inserimento oppure null se non è stata generata alcuna eccezione.

Esempio

Nell'esempio seguente viene illustrato come utilizzare l'oggetto ListViewInsertedEventArgs passato a un gestore per l'evento ItemInserted per determinare se è stata generata un'eccezione durante l'operazione di inserimento. Questo esempio di codice fa parte di un esempio più ampio fornito per 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

Commenti

Se è stata generata un'eccezione e si gestisce l'eccezione nel gestore eventi, impostare la ExceptionHandled proprietà su true. In caso contrario, il ListView controllo genera nuovamente l'eccezione.

Si applica a

Vedi anche