Click here to Skip to main content
14,693,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

I have one problem with datagridview. I want to multiplying two cells and display the result in third cell

A     | B  |  C
10.50 | 2  | 21,00
5.20  | 4  | 20,80
7,3   | 5  | 36,50

after that i wanna to sum C column and display that in textBox.
Column A is type decimal
Column B is integer
Column C should be decimal too

how to do that and how to display decimal value in textbox?

This is what I have trie
foreach (DataGridViewRow item in dataGridView1.Rows)
  int n = item.Index;
  dataGridView1.Rows[n].Cells[2].Value = 
      (Double.Parse(dataGridView1.Rows[n].Cells[0].Value.ToString()) +

textBox1.Text = "0";
foreach (DataGridViewRow item in dataGridView1.Rows)
  int n = item.Index;
  textBox1.Text = (Double.Parse(textBox1.Text.ToString()) +     
this code should sum cells, but i want to multiplying cells. i was trying to do anything!
Updated 1-Jun-13 1:53am
Please post what have you tried so far ?

1 solution


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900