//Do it private void DgvExamList_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && this.dgvExamList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals(Constants.DO_IT)) { Form parentForm = (Form)this.Parent.Parent.Parent.Parent; FormPassValue.languageState = Thread.CurrentThread.CurrentCulture.ToString(); FormPassValue.currentWindowState = parentForm.WindowState; ExamDescription examDescription = new ExamDescription(); FormPassValue.examId = Convert.ToInt32(this.dgvExamList.Rows[e.RowIndex].Cells[2].Value); DialogResult result = examDescription.ShowDialog(); if (result == DialogResult.OK) { //Don't write outside, that run form take exam timer FormTakeExam formTakeExam = new FormTakeExam(); //Show take exam form and transfer main form object formTakeExam.Show(parentForm); //Hide main form parentForm.Hide(); } } }
//Do it private void dgvExamList_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && this.dgvExamList.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals(Constants.doIt)) { ExamDescription examDescription = new ExamDescription(); //transfer examId FormPassValue.examId = Convert.ToInt32(this.dgvExamList.Rows[e.RowIndex].Cells[2].Value); DialogResult result = examDescription.ShowDialog(); if (result == DialogResult.OK) { //avoid write outside, that run form take exam timer FormTakeExam formTakeExam = new FormTakeExam(); //show take exam form and transfer main form object formTakeExam.Show(this.Parent.Parent.Parent.Parent.Parent); //Hide main form this.Parent.Parent.Parent.Parent.Parent.Hide(); } } }