110,538
社区成员
发帖
与我相关
我的任务
分享
int num = dGV_Record.Rows.GetRowCount(DataGridViewElementStates.Visible);
for (int i = 0; i < num; i++)
num-1了。string IOExpenditure = dGV_Record.Rows[i].Cells[0].Value.ToString();
如果为空倒是简单了,现在是赋值成功并且插入数据库了。
麻烦请仔细看看,谢谢。
至于那个不为空弹窗,那三层下来都不为空,才会弹窗,if是嵌套的。if (dGV_Record.Rows[i] != null)
{
if (dGV_Record.Rows[i].Cells[0] != null)
{
if (dGV_Record.Rows[i].Cells[0].Value != null)
{
MessageBox.Show(dGV_Record.Rows[i].Cells[0].Value.ToString());
}
messagebox消息有提示,提示了内容。int num = dGV_Record.Rows.GetRowCount(DataGridViewElementStates.Visible);
for (int i = 0; i < num; i++)
这段代码是出错语句之前的代码,如果dGV_Record为null,那就不会进入循环内部了啊。这出错是什么机制?
总不能用try{}catch{}屏蔽吧。