DataGridViewRowCancelEventArgs Klasa

Definicja

Dostarcza dane dla UserDeletingRow zdarzenia obiektu DataGridView.

public ref class DataGridViewRowCancelEventArgs : System::ComponentModel::CancelEventArgs
public class DataGridViewRowCancelEventArgs : System.ComponentModel.CancelEventArgs
type DataGridViewRowCancelEventArgs = class
    inherit CancelEventArgs
Public Class DataGridViewRowCancelEventArgs
Inherits CancelEventArgs
Dziedziczenie
DataGridViewRowCancelEventArgs

Przykłady

Poniższy przykład kodu ilustruje użycie tego typu. Ten przykład jest częścią większego przykładu dostępnego w temacie Instrukcje: implementowanie trybu wirtualnego w kontrolce DataGridView Windows Forms.

void dataGridView1_UserDeletingRow( Object^ /*sender*/,
    System::Windows::Forms::DataGridViewRowCancelEventArgs^ e )
{
   if ( e->Row->Index < this->customers->Count )
   {
      
      // If the user has deleted an existing row, remove the 
      // corresponding Customer object from the data store.
      this->customers->RemoveAt( e->Row->Index );
   }

   if ( e->Row->Index == this->rowInEdit )
   {
      
      // If the user has deleted a newly created row, release
      // the corresponding Customer object. 
      this->rowInEdit = -1;
      this->customerInEdit = nullptr;
   }
}
private void dataGridView1_UserDeletingRow(object sender,
    System.Windows.Forms.DataGridViewRowCancelEventArgs e)
{
    if (e.Row.Index < this.customers.Count)
    {
        // If the user has deleted an existing row, remove the 
        // corresponding Customer object from the data store.
        this.customers.RemoveAt(e.Row.Index);
    }

    if (e.Row.Index == this.rowInEdit)
    {
        // If the user has deleted a newly created row, release
        // the corresponding Customer object. 
        this.rowInEdit = -1;
        this.customerInEdit = null;
    }
}
Private Sub dataGridView1_UserDeletingRow(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs) _
    Handles dataGridView1.UserDeletingRow

    If e.Row.Index < Me.customers.Count Then

        ' If the user has deleted an existing row, remove the 
        ' corresponding Customer object from the data store.
        Me.customers.RemoveAt(e.Row.Index)

    End If

    If e.Row.Index = Me.rowInEdit Then

        ' If the user has deleted a newly created row, release
        ' the corresponding Customer object. 
        Me.rowInEdit = -1
        Me.customerInEdit = Nothing

    End If

End Sub

Uwagi

Aby anulować usunięcie wiersza w procedurze UserDeletingRow obsługi zdarzeń, ustaw Cancel właściwość na truewartość .

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Konstruktory

DataGridViewRowCancelEventArgs(DataGridViewRow)

Inicjuje nowe wystąpienie klasy DataGridViewRowCancelEventArgs.

Właściwości

Cancel

Pobiera lub ustawia wartość wskazującą, czy zdarzenie powinno zostać anulowane.

(Odziedziczone po CancelEventArgs)
Row

Pobiera wiersz, który użytkownik usuwa.

Metody

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera wartość bieżącego wystąpienia.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Zobacz też