【求助】关于DataGridView的一段代码问题。。。
程序代码: if (dgvQuestionList.SelectedRows[0].Cells["Question"].Value.ToString() == "")
{
MessageBox.Show("题目不能为空","提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (dgvQuestionList.SelectedRows[0].Cells["OptionA"].Value.ToString() == "" || dgvQuestionList.SelectedRows[0].Cells["OptionB"].Value.ToString() == "" || dgvQuestionList.SelectedRows[0].Cells["OptionC"].Value.ToString() == "" || dgvQuestionList.SelectedRows[0].Cells["OptionD"].Value.ToString() == "")
{
MessageBox.Show("选项不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (dgvQuestionList.SelectedRows[0].Cells["Answer"].Value.ToString() == "")
{
MessageBox.Show("答案不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else if (dgvQuestionList.SelectedRows[0].Cells["Difficulty"].Value.ToString() == "")
{
MessageBox.Show("难度不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}想实现对DataGridView中数据的修改,但我想先进行修改的非空判断,就凭感觉
这么写出来了,结果用try catch保住就数据异常了ex是:{"索引超出范围。必须为非负值并小于集合大小。\r\n参数名: index"}
这个是什么意思呢??


怎么修改呀。。。
望指教!









