public void DisplayQuestion(bool ShowQuestion, bool ShowAnswer) { if (!isPrintPreviewTaken) { GenerateQuestions(); isPrintPreviewTaken = true; } FrmQuestionsDisplay obj = new FrmQuestionsDisplay(); //obj.resultQuestions.objQuestionDetail.Clear(); obj.resultQuestions.objQuestionDetail = objQuestions.objQuestionDetail; if (treeView1.SelectedNode.Level == 0) { obj.strQuestTopic = treeView1.SelectedNode.Text; } if (treeView1.SelectedNode.Level == 1) { obj.strQuestTopic = treeView1.SelectedNode.Parent.Text; obj.strSubject = treeView1.SelectedNode.Text; } if (treeView1.SelectedNode.Level == 2) { obj.strQuestTopic = treeView1.SelectedNode.Parent.Parent.Text; obj.strSubject = treeView1.SelectedNode.Text; } // obj.strSubject = groupBox1.GroupTitle;// ""; // obj.strQuestTopic = ""; obj.printAnswer = ShowAnswer; obj.printQuestion = ShowQuestion; obj.ShowDialog(); }
void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 6) { if (DialogResult.Yes == MessageBox.Show("Are you sure to delete from list?", "Delete", MessageBoxButtons.YesNo)) { File.Delete(objQuestionManagementColl.objQuestionManagement[e.RowIndex].FileName); objQuestionManagementColl.objQuestionManagement.RemoveAt(e.RowIndex); ObjectXMLSerializer <QuestionManagementColl> .Save(objQuestionManagementColl, Application.StartupPath + Utility.FolderType() + @"QuestionPaper\QuestionInfo.txt"); LoadTextData(); } } else if (e.ColumnIndex > 1 && (e.ColumnIndex < 6)) { QuestionDetailData objQuestions = ObjectXMLSerializer <QuestionDetailData> .Load(objQuestionManagementColl.objQuestionManagement[e.RowIndex].FileName); FrmQuestionsDisplay obj = new FrmQuestionsDisplay(); //obj.resultQuestions.objQuestionDetail.Clear(); obj.resultQuestions.objQuestionDetail = objQuestions.objQuestionDetail; obj.strSubject = objQuestionManagementColl.objQuestionManagement[e.RowIndex].Subject; obj.strQuestTopic = objQuestionManagementColl.objQuestionManagement[e.RowIndex].QuestionTopic; if (e.ColumnIndex == 2) { obj.printAnswer = false; obj.printQuestion = true; } else if (e.ColumnIndex == 3) { obj.printAnswer = true; obj.printQuestion = true; } else if (e.ColumnIndex == 4) { obj.printAnswer = true; obj.printQuestion = false; } else if (e.ColumnIndex == 5) { obj.printAnswer = false; obj.printQuestion = false; } obj.ShowDialog(); } }