看看这段代码 - 我完成了datagridview的CellEndEdit事件
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.ColumnIndex == 1)
{
if (dataGridView1.Rows[e.RowIndex].Cells[1].Value == null)
{
dataGridView1.Rows[e.RowIndex].Cells[4].Value = dataGridView1.Rows[0].Cells[6].Value;
}
else
{
con.Close();
if (_chkval == 0)
{
con.Open();
string query2 = "select [मालमत्ता क्रमांक] from नमुना८_मालमत्तेची_माहिती where [मालमत्ता क्रमांक] = '" + dataGridView1.CurrentRow.Cells[1].Value + "' ";
OleDbCommand adp2 = new OleDbCommand(query2, con);
OleDbDataReader dr = adp2.ExecuteReader();
if (dr.HasRows && dataGridView1.Rows[e.RowIndex].Cells[1].Value != null)
{
DialogResult result = MsgBox.Show("मालमत्ता क्रमांक अस्तित्वात आहे.", "सुचना", MsgBox.Buttons.OK, MsgBox.Icon.Warning, MsgBox.AnimateStyle.FadeIn);
dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[1];
this.dataGridView1.BeginEdit(false);
}
con.Close();
}
}