private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (OperatorBindingSource.Current == null) { return; } GridViewOper.CloseEditor(); if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes) { modified = false; newRec = false; IEnumerable <CONTACT> contactRecs = from contact in context.CONTACT where contact.LINK_VALUE == TextEditCode.Text select contact; foreach (CONTACT rec in contactRecs) { context.DeleteObject(rec); } IEnumerable <RptContact> rptContactRecs = from contact in context.RptContact where contact.Code == TextEditCode.Text select contact; foreach (RptContact rec in rptContactRecs) { context.DeleteObject(rec); } OperatorBindingSource.RemoveCurrent(); errorProvider1.Clear(); context.SaveChanges(); setReadOnly(true); panelControlStatus.Visible = true; LabelStatus.Text = "Record Deleted"; rowStatusDelete = new Timer(); rowStatusDelete.Interval = 3000; rowStatusDelete.Start(); rowStatusDelete.Tick += new EventHandler(TimedEventDelete); } TextEditCode.Focus(); currentVal = TextEditCode.Text; modified = false; newRec = false; }