DataGridView.CancelRowEdit 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
DataGridView 컨트롤의 VirtualMode 속성이 true
일 때 발생하며 행의 편집 내용을 취소합니다.
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
이벤트 유형
예제
다음 코드 예제에서는 가상 모드에서 컨트롤에 대 한이 이벤트를 처리 하는 DataGridView 방법을 보여 줍니다. 컨트롤이 편집 모드 rowInEdit
에 있는 경우 변수는 편집 중인 행의 인덱스가 있고 customerInEdit
변수는 해당 행에 해당하는 Customer 개체에 대한 참조를 보유합니다. 사용자가 편집 모드에서 취소하면 이 개체를 삭제할 수 있습니다. 그러나 사용자가 편집 중인 행이 새 레코드의 행인 경우 이전 Customer 개체는 삭제되고 사용자가 다시 편집을 시작할 수 있도록 새 개체로 바뀝니다. 이 예제는 연습: Windows Forms DataGridView 컨트롤에서 가상 모드 구현에서 사용할 수 있는 더 큰 예제의 일부입니다.
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
설명
가 DataGridView 가상 모드에 있는 경우 변경 내용은 기본적으로 셀 수준에서 데이터 캐시에 커밋됩니다. 행 CancelRowEdit 수준 트랜잭션을 구현할 때 이벤트를 사용할 수 있습니다.
이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.
적용 대상
추가 정보
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기