Share via


DataGridViewRowCancelEventArgs Kelas

Definisi

Menyediakan data untuk UserDeletingRow peristiwa DataGridView.

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

Contoh

Contoh kode berikut mengilustrasikan penggunaan jenis ini. Contoh ini adalah bagian dari contoh yang lebih besar yang tersedia di Cara: Menerapkan Mode Virtual di kontrol Formulir Windows DataGridView.

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

Keterangan

Untuk membatalkan penghapusan baris dalam UserDeletingRow penanganan aktivitas, atur properti ke Canceltrue.

Untuk informasi selengkapnya tentang cara menangani peristiwa, lihat Menangani dan Menaikkan Peristiwa.

Konstruktor

DataGridViewRowCancelEventArgs(DataGridViewRow)

Menginisialisasi instans baru kelas DataGridViewRowCancelEventArgs.

Properti

Cancel

Mendapatkan atau menetapkan nilai yang menunjukkan apakah acara harus dibatalkan.

(Diperoleh dari CancelEventArgs)
Row

Mendapatkan baris yang dihapus pengguna.

Metode

Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan instans Type saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari yang saat ini Object.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga