Example #1
0
 private void GroupsDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     if (e.ColumnIndex == GroupsDataGridView.Rows[e.RowIndex].Cells["FirstName"].ColumnIndex ||
         e.ColumnIndex == GroupsDataGridView.Rows[e.RowIndex].Cells["LastName"].ColumnIndex ||
         e.ColumnIndex == GroupsDataGridView.Rows[e.RowIndex].Cells["Patronymic"].ColumnIndex)
     {
         ManageTeacherGroupsDialog dialog = new ManageTeacherGroupsDialog();
         dialog.Owner        = this;
         dialog.FormClosing += (o, s) =>
         {
             try
             {
                 if ((o as ManageTeacherGroupsDialog).TeacherID != 0)
                 {
                     GroupsDataGridView["TeacherID", e.RowIndex].Value  = (o as ManageTeacherGroupsDialog).TeacherID;
                     GroupsDataGridView["LastName", e.RowIndex].Value   = (o as ManageTeacherGroupsDialog).LastName;
                     GroupsDataGridView["FirstName", e.RowIndex].Value  = (o as ManageTeacherGroupsDialog).FirstName;
                     GroupsDataGridView["Patronymic", e.RowIndex].Value = (o as ManageTeacherGroupsDialog).Patronymic;
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         };
         dialog.ShowDialog();
     }
 }
 private void GroupsDataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     if (e.ColumnIndex == GroupsDataGridView.Rows[e.RowIndex].Cells["FirstName"].ColumnIndex ||
         e.ColumnIndex == GroupsDataGridView.Rows[e.RowIndex].Cells["LastName"].ColumnIndex ||
         e.ColumnIndex == GroupsDataGridView.Rows[e.RowIndex].Cells["Patronymic"].ColumnIndex)
     {
         ManageTeacherGroupsDialog dialog = new ManageTeacherGroupsDialog();
         dialog.Owner = this;
         dialog.FormClosing += (o, s) =>
             {
                 try
                 {
                     if ((o as ManageTeacherGroupsDialog).TeacherID != 0)
                     {
                         GroupsDataGridView["TeacherID", e.RowIndex].Value = (o as ManageTeacherGroupsDialog).TeacherID;
                         GroupsDataGridView["LastName", e.RowIndex].Value = (o as ManageTeacherGroupsDialog).LastName;
                         GroupsDataGridView["FirstName", e.RowIndex].Value = (o as ManageTeacherGroupsDialog).FirstName;
                         GroupsDataGridView["Patronymic", e.RowIndex].Value = (o as ManageTeacherGroupsDialog).Patronymic;
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             };
         dialog.ShowDialog();
     }
 }