winform中datagridview控件问题

awefire 2016-05-13 10:43:49
double num15 = 0;
for (int i = 0; i < (a - 1); i++)
{
string value = Convert.ToString(dataGridView1.Rows[i].Cells[4].Value);
double num16 = Convert.ToDouble(dataGridView1.Rows[i+1].Cells[3].Value);
double num17 = Convert.ToDouble(dataGridView1.Rows[i].Cells[2].Value);
if (!string.IsNullOrEmpty(value))
{
num15 = num16 * Math.Cos(num17 * 180 / Math.PI);
}
dataGridView1.Rows[i].Cells[4].Value = num15.ToString();
}
代码如上,就是在datagridview控件生成的表格里面进行数据计算,但是它计算出来都显示为0是什么情况?
求教
...全文
97 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
xdashewan 2016-05-13
  • 打赏
  • 举报
回复
引用 2 楼 f_heaven 的回复:
我确定不是空
断点调试,没别的法子了
awefire 2016-05-13
  • 打赏
  • 举报
回复
我确定不是空
awefire 2016-05-13
  • 打赏
  • 举报
回复
嗯,我试试谢谢了
  • 打赏
  • 举报
回复
断点调试看下num16和num17的值
xdashewan 2016-05-13
  • 打赏
  • 举报
回复
if (!string.IsNullOrEmpty(value))不是空才计算,你确定Convert.ToString(dataGridView1.Rows[i].Cells[4].Value);不是空吗?

110,552

社区成员

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

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

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