在DataGridView中乘以列 [英] Multiplying columns in DataGridView

查看:79
本文介绍了在DataGridView中乘以列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

请将列中的条目与其他列条目相乘,结果将在DataGridView的另一列中



这就是我用的东西,但什么也没出来





Hello
please I want to multiply entries in a column with another column entries and the result will be in another column of the DataGridView

this was what i used but nothing is coming up


private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
   int crsUn, cmb;
   for (int i = 0; i < dataGridView1.Rows.Count; i++)
   {
       if (int.TryParse(dataGridView1.Rows[i].Cells[2].Value.ToString(), out crsUn) && int.TryParse(dataGridView1.Rows[i].Cells[4].Value.ToString(), out cmb))
       {
           int gp = crsUn * cmb; 
           dataGridView1.Rows[i].Cells[5].Value = gp.ToString();
       }
   }
}





删除了SHOUTING,添加了代码块 - OriginalGriff [ / edit]



[edit]SHOUTING removed, Code block added - OriginalGriff[/edit]

推荐答案

可能你的问题是这个问题的重复:

如何在DataGridView中将列的值相乘并向其显示另一列 [ ^ ]

另见:

如何在datagridview中将第三列的两列数据相乘 [ ^ ]

datagridview乘以单元格值 [ ^ ]
Possibly your question is a duplication of this question:
how to multiply the value of column in DataGridView and show it another column[^]
Also see:
How to multiply data of two columns for third column in datagridview[^]
datagridview multiplying cell value[^]


这篇关于在DataGridView中乘以列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆