private void cb_course_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { int icol = Convert.ToInt16(datagridView.CurrentCellAddress.X.ToString()); int irow = Convert.ToInt16(datagridView.CurrentCellAddress.Y.ToString()); //checking the clashing for (int i = 0; i < datagridView.Columns.Count; i++) { if (datagridView[i, irow].Value != null) { if (datagridView[i, irow].Value.ToString().Trim() == cb_Course.Text.ToString().Trim()) { String Msg = "Selected course is already alloacted in " + datagridView.Columns[i].HeaderText; DialogResult Results; Results = MessageBox.Show(Msg, "Clashing", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Results == System.Windows.Forms.DialogResult.No) { return; } } } } cb_Course.Visible = false; cb_Course.Focus(); datagridView[datagridView.CurrentCellAddress.X, datagridView.CurrentCellAddress.Y].Value = cb_Course.Text; datagridView.Focus(); } if (e.KeyCode == Keys.Escape) { cb_Course.Visible = false; datagridView.Focus(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)