0
Windows 양식 응용 프로그램. C# 4.0.DataGridViewRowCancelEventArgs가 실행되지 않습니다.
Windows 용 MS SQL 테이블에 datgridview를 바인딩했습니다. 거기에 삭제 버튼이 있습니다. 행을 선택하고 버튼을 클릭하면 행을 삭제하고 싶습니다. 그것은 잘 끝났습니다. 하지만 작업을 삭제하기 전에 미리 알림을 추가하고 싶습니다. 그러나 나는 그것이 작동하지 않는 것을 알았다. dgv_UserDeletingRow 이벤트는 실행되지 않습니다.
private void DeleteRow_Click(object sender, EventArgs e)
{
try
{
DataRowView currentDataRowView = (DataRowView)dgv.CurrentRow.DataBoundItem;
DataRow row = currentDataRowView.Row;
// Delete Table here and successfully
}
catch (Exception exceptionObj)
{
MessageBox.Show(exceptionObj.Message.ToString());
}
}
private void dgv_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
{
if (!e.Row.IsNewRow)
{
DialogResult res = MessageBox.Show("Are you sure you want to delete this row?", "Delete confirmation",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (res == DialogResult.No)
e.Cancel = true;
}
}
감사합니다.