DataGridView.CancelRowEdit Olay

Tanım

Bir DataGridView denetimin VirtualMode özelliği olduğunda true ve bir satırdaki düzenlemeleri iptal ettiğinde gerçekleşir.

public:
 event System::Windows::Forms::QuestionEventHandler ^ CancelRowEdit;
public event System.Windows.Forms.QuestionEventHandler CancelRowEdit;
public event System.Windows.Forms.QuestionEventHandler? CancelRowEdit;
member this.CancelRowEdit : System.Windows.Forms.QuestionEventHandler 
Public Custom Event CancelRowEdit As QuestionEventHandler 

Olay Türü

Örnekler

Aşağıdaki kod örneği, sanal modda bir DataGridView denetim için bu olayın nasıl işleyebileceğinizi göstermektedir. Denetim düzenleme modundayken değişken, rowInEdit düzenlenmekte olan satırın dizinini, değişken ise customerInEdit bu satıra karşılık gelen bir Customer nesnesine başvuruyu tutar. Kullanıcı düzenleme modunu iptal ettiğinde, bu nesne atılabilir. Ancak kullanıcının düzenlediği satır yeni kayıtların satırıysa, eski Customer nesnesi atılır ve yenisiyle değiştirilir, böylece kullanıcı düzenleme yapmaya yeniden başlayabilir. Bu örnek, İzlenecek Yol: Windows Forms DataGridView Denetiminde Sanal Mod Uygulama başlığı altında sağlanan daha büyük bir örneğin parçasıdır.

void dataGridView1_CancelRowEdit( Object^ /*sender*/,
    System::Windows::Forms::QuestionEventArgs^ /*e*/ )
{
   if ( this->rowInEdit == this->dataGridView1->Rows->Count - 2 &&
        this->rowInEdit == this->customers->Count )
   {
      
      // If the user has canceled the edit of a newly created row, 
      // replace the corresponding Customer object with a new, empty one.
      this->customerInEdit = gcnew Customer;
   }
   else
   {
      
      // If the user has canceled the edit of an existing row, 
      // release the corresponding Customer object.
      this->customerInEdit = nullptr;
      this->rowInEdit = -1;
   }
}
private void dataGridView1_CancelRowEdit(object sender,
    System.Windows.Forms.QuestionEventArgs e)
{
    if (this.rowInEdit == this.dataGridView1.Rows.Count - 2 &&
        this.rowInEdit == this.customers.Count)
    {
        // If the user has canceled the edit of a newly created row, 
        // replace the corresponding Customer object with a new, empty one.
        this.customerInEdit = new Customer();
    }
    else
    {
        // If the user has canceled the edit of an existing row, 
        // release the corresponding Customer object.
        this.customerInEdit = null;
        this.rowInEdit = -1;
    }
}
Private Sub dataGridView1_CancelRowEdit(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.QuestionEventArgs) _
    Handles dataGridView1.CancelRowEdit

    If Me.rowInEdit = Me.dataGridView1.Rows.Count - 2 AndAlso _
        Me.rowInEdit = Me.customers.Count Then

        ' If the user has canceled the edit of a newly created row, 
        ' replace the corresponding Customer object with a new, empty one.
        Me.customerInEdit = New Customer()

    Else

        ' If the user has canceled the edit of an existing row, 
        ' release the corresponding Customer object.
        Me.customerInEdit = Nothing
        Me.rowInEdit = -1

    End If

End Sub

Açıklamalar

DataGridView sanal modda olduğunda, değişiklikler varsayılan olarak hücre düzeyinde veri önbelleğine işlenir. Olay, CancelRowEdit satır düzeyi işlemler uygulanırken kullanılabilir.

Olayları işleme hakkında daha fazla bilgi için bkz. Olayları İşleme ve Oluşturma.

Şunlara uygulanır

Ayrıca bkz.