'sum of column based on another column will show on another

Can you help me with my DataGridView? I need to show sum of column based on another column.

For example, I have Part number 1,2,3. QTY for PN is always 1 because of the serial number given.

PN 1 has 10qty (10rows). I need to sum it based on that PN and put the sum value at the end cell. Please see below sample:

Sample datagridview

It is excel I know, but just please bear with me pretend it is DataGridView.

Total sum is based on sum of cost for the same PN.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source