Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

c# sum checked rows

$
0
0

Hi, I added a column checkBox as column9 in datagridview. I need get sum of rows column6 if column9 checked is true. I have this code:

private void dataGridView2_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {

            int sum = 0;
            for (int i = 0; i < dataGridView2.SelectedRows.Count; i++)
            {
                sum += Convert.ToInt32(dataGridView2.Rows[i].Cells[6].Value);
            }

            test.Text = sum.ToString();
        }

Please help me


Viewing all articles
Browse latest Browse all 2535

Trending Articles