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

C# Datagridview sum of each group

$
0
0

Hi all,

i have a datagridview with two columns (Group& Qty).

            int _total = 0;
            for (int c = 0; c < GridView1.Columns.Count; ++c)
            {

                for (int i = 0; i < GridView1.Rows.Count; ++i)
                {

                    _total += Convert.ToInt32(GridView1.Rows[i].Cells["QTY"].Value);

                }
            }


//I don't know how to combine both Column and Row loops :S

I would like to have the sum of each group.  

GroupQty

A12
B14
C22
A9
C17
B1
A3

I have to get a return (MessageBox for example):
A24
B=15
=39

Thank you,


Please do not forget to click “Vote as Helpful” if the reply helps/directs you toward your solution and or "Mark as Answer" if it solves your question. This will help to contribute to the forum.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>