索引超出了数组界限,急!!!!!

YYBYYB1984 2008-09-23 11:04:38
int num=0;
foreach (DataGridViewRow dgvRow in dgvCharge.Rows)
{
if (dgvRow.Cells["dgvcbc"] != null && dgvRow.Cells["dgvcbc"].Value != null)
if (dgvRow.Cells["dgvcbc"].Value.Equals(true))
{
------------------------下一行报错
PayInfo.ComputeChargeRecordID[num] = Convert.ToInt32(dgvRow.Cells["colChargeID"].Value);

decimal remainMoney = Convert.ToDecimal(dgvRow.Cells["colRemainMoney"].Value);
decimal remainWater = Convert.ToDecimal(dgvRow.Cells["colRemainWater"].Value);

DataSet ds = bll.GetChargeDetailInfo(PayInfo.ComputeChargeRecordID[num]);
decimal recMoney = 0;
decimal factMoney = 0;

decimal recLateFee = 0;
decimal discountMoney = 0;
decimal cutLateFee = 0;
decimal factualLateFee = 0;
PayInfo.FactualMoney[num] = Convert.ToDouble(factMoney);
PayInfo.PayWaterMuch[num] = Convert.ToDouble(remainWater * factMoney / remainMoney);
PayInfo.ReceivableMoney[num] = PayInfo.FactualMoney[num];
PayInfo.ReceivableWater[num] = PayInfo.PayWaterMuch[num];
PayInfo.ReceivableLateFee[num] = Convert.ToDouble(recLateFee);
PayInfo.ChargeDiscount[num] = Convert.ToDouble(discountMoney);
PayInfo.LateFeeDiscount[num] = Convert.ToDouble(cutLateFee);
PayInfo.FactualLateFee[num] = Convert.ToDouble(factualLateFee);
PayInfo.PlanInWater[num] = Convert.ToDouble(dgvRow.Cells["PlanInWater"].Value.ToString());
PayInfo.PlanInMoney[num] = Convert.ToDouble(dgvRow.Cells["PlanInMoney"].Value.ToString());
PayInfo.PlanOutWater[num] = Convert.ToDouble(dgvRow.Cells["PlanOutWater"].Value.ToString());
PayInfo.PlanOutMoney[num] = Convert.ToDouble(dgvRow.Cells["PlanOutMoney"].Value.ToString());
num++;
}
}
}

为什么???
...全文
109 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengyecsdn 2008-09-23
  • 打赏
  • 举报
回复
帮顶~ 关注~ 签名~ 留念~ 接分
消失的尘芥 2008-09-23
  • 打赏
  • 举报
回复
if (dgvRow.Cells["dgvcbc"] != null && dgvRow.Cells["dgvcbc"].Value != null && dgvRow.Cells.Count>0)
YYBYYB1984 2008-09-23
  • 打赏
  • 举报
回复
是选择超过两行后会出错,很郁闷。
不晓得为什么?
zpcoder 2008-09-23
  • 打赏
  • 举报
回复
if (dgvRow.Cells["dgvcbc"] != null && dgvRow.Cells["dgvcbc"].Value != null)


------------>


if (dgvRow.Cells["dgvcbc"] != null && dgvRow.Cells["dgvcbc"].Value != null && dgvRow.Cells.Count>0)
YYBYYB1984 2008-09-23
  • 打赏
  • 举报
回复
DataGridView 中选择超过两行就会报这个错!

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧