private void btnAddAns_Click(object sender, EventArgs e) { if (File.Exists(tbAnswerFile.Text)) { frmaddProData = new frmAddProData(tbAnswerFile.Text); frmaddProData.ShowDialog(); if (frmaddProData.Result == true) { AnsList.Add(frmaddProData.ProAns); dtAnsList.Rows.Add(new object[2] { frmaddProData.ProAns.Input, frmaddProData.ProAns.Output }); } } else { MessageBox.Show("文件不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvAnsList.CurrentRow != null && dgvAnsList.CurrentRow.Index >= 0) { frmaddProData = new frmAddProData(tbAnswerFile.Text, AnsList[dgvAnsList.CurrentRow.Index]); frmaddProData.ShowDialog(); if (frmaddProData.Result == true) { dtAnsList.Rows[dgvAnsList.CurrentRow.Index][0] = frmaddProData.ProAns.Input; dtAnsList.Rows[dgvAnsList.CurrentRow.Index][1] = frmaddProData.ProAns.Output; AnsList[dgvAnsList.CurrentRow.Index] = frmaddProData.ProAns; } } else { MessageBox.Show("未选择答案", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }