private void dgvPaperInfo_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex != -1) { int recordCount = Convert.ToInt32(dgvPaperInfo.Rows[e.RowIndex].Cells[0].Value); if (e.ColumnIndex == 1 && recordCount == 0) { int id = Convert.ToInt32(dgvPaperInfo.Rows[e.RowIndex].Cells[2].Value); dialog = new AnswerDialog(); dialog.paperId = id; this.MdiParent.Hide(); if (dialog.ShowDialog() == DialogResult.OK) { showAllPapers(); this.MdiParent.Show(); } } } }
private void layoutAllQuestions(List <Question> blist, List <Question> salist) { lblPaperName.Location = new Point((this.Width - lblPaperName.Width) / 2, 9); mark = lblPaperName.Location.Y + lblPaperName.Height; //按下NumericUpDown控件的上或下箭头1s后,数值变化将以5为单位 NumericUpDownAcceleration acceleration = new NumericUpDownAcceleration(1, 5); int i; if (blist.Count != 0) { //填空题 i = 0; Label blbl = new Label(); blbl.Text = "填空题部分"; blbl.AutoSize = true; this.Controls.Add(blbl); blbl.Location = new Point(SPACE, mark + 2 * SPACE); int hit = blbl.Location.Y + 2 * SPACE; foreach (Question question in blist) { Label lbl = new Label(); lbl.Text = (i + 1) + "." + question.question + "(" + question.mark + "分)"; i++; lbl.Width = 50 * SPACE; lbl.Height = AnswerDialog.getLineNum(lbl.Text) * SPACE; this.Controls.Add(lbl); lbl.Location = new Point(SPACE, hit); hit += (lbl.Height + 7 * SPACE); Label answerlbl = new Label(); answerlbl.Text = "参考答案:" + question.answer; answerlbl.Width = 50 * SPACE; answerlbl.Height = AnswerDialog.getLineNum(answerlbl.Text) * SPACE; this.Controls.Add(answerlbl); answerlbl.Location = new Point(SPACE, lbl.Location.Y + lbl.Height + 6); Label stuAnswerlbl = new Label(); stuAnswerlbl.Text = "学员答案:" + question.stuAnswer; stuAnswerlbl.Width = 50 * SPACE; stuAnswerlbl.Height = AnswerDialog.getLineNum(stuAnswerlbl.Text) * SPACE; this.Controls.Add(stuAnswerlbl); stuAnswerlbl.Location = new Point(SPACE, answerlbl.Location.Y + answerlbl.Height + 6); MyNumericUpDown nud = new MyNumericUpDown(); nud.Width = 6 * SPACE; nud.Maximum = question.mark; nud.Minimum = 0; nud.Increment = 1; nud.Accelerations.Add(acceleration); this.Controls.Add(nud); nud.Location = new Point(SPACE, stuAnswerlbl.Location.Y + stuAnswerlbl.Height + 6); mark = nud.Location.Y + nud.Height; } } if (salist.Count != 0) { //简答题 i = 0; Label salbl = new Label(); salbl.Text = "简答题部分"; salbl.AutoSize = true; this.Controls.Add(salbl); salbl.Location = new Point(SPACE, mark + 2 * SPACE); int hit = salbl.Location.Y + 2 * SPACE; foreach (Question question in salist) { Label lbl = new Label(); lbl.Text = (i + 1) + "." + question.question + "(" + question.mark + "分)"; i++; lbl.Width = 50 * SPACE; lbl.Height = AnswerDialog.getLineNum(lbl.Text) * SPACE; this.Controls.Add(lbl); lbl.Location = new Point(SPACE, hit); hit += (lbl.Height + 7 * SPACE); Label answerlbl = new Label(); answerlbl.Text = "参考答案:" + question.answer; answerlbl.Width = 50 * SPACE; answerlbl.Height = AnswerDialog.getLineNum(answerlbl.Text) * SPACE; this.Controls.Add(answerlbl); answerlbl.Location = new Point(SPACE, lbl.Location.Y + lbl.Height + 6); Label stuAnswerlbl = new Label(); stuAnswerlbl.Text = "学员答案:" + question.stuAnswer; stuAnswerlbl.Width = 50 * SPACE; stuAnswerlbl.Height = AnswerDialog.getLineNum(stuAnswerlbl.Text) * SPACE; this.Controls.Add(stuAnswerlbl); stuAnswerlbl.Location = new Point(SPACE, answerlbl.Location.Y + answerlbl.Height + 6); MyNumericUpDown nud = new MyNumericUpDown(); nud.Width = 6 * SPACE; nud.Maximum = question.mark; nud.Minimum = 0; nud.Increment = 1; nud.Accelerations.Add(acceleration); this.Controls.Add(nud); nud.Location = new Point(SPACE, stuAnswerlbl.Location.Y + stuAnswerlbl.Height + 6); mark = nud.Location.Y + nud.Height; } } Button btnOk = new Button(); btnOk.Click += new EventHandler(btnOk_Click); btnOk.Text = "提交"; btnOk.Width = 6 * SPACE; btnOk.Height = 2 * SPACE; this.Controls.Add(btnOk); Button btnCancel = new Button(); btnCancel.Click += new EventHandler(btnCancel_Click); btnCancel.Text = "取消"; btnCancel.Width = 6 * SPACE; btnCancel.Height = 2 * SPACE; this.Controls.Add(btnCancel); btnOk.Location = new Point((this.Width - btnOk.Width - btnCancel.Width) / 3, mark + 3 * SPACE); btnCancel.Location = new Point(btnOk.Location.X + btnOk.Width + (this.Width - btnOk.Width - btnCancel.Width) / 3, mark + 3 * SPACE); }