Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1)Create a List of strings with all rows of column 'Consumable Name'. Fill with names.</p> <p>2)Create a List of integers equal to the number of items in the above List. Fill with quantities.</p> <p>3)Create a List of distinct strings from (1).</p> <p>4)Create a List of integers equal to the number of items in (3).</p> <p>5)Step into each distinct element and get the related matching 'Consumable Name' and add quantities.</p> <p>6)Similar steps you can follow if you wish to compare or check other columns.</p> <p>You can refer to the below code:</p> <pre><code> public void getQuantity() { List&lt;string&gt; consumbleNames = new List&lt;string&gt;(); List&lt;int&gt; quantity = new List&lt;int&gt;(); //Cells[5] refer to 6th column : Quantity issued: you can use column name too for (int i = 0; i &lt; yourDataGridView.Rows.Count; i++) { consumbleNames.Add(yourDataGridView.Rows[i].Cells[0].Value.ToString()); quantity.Add((int)Convert.ToInt32(yourDataGridView.Rows[i].Cells[5].Value.ToString())); } List&lt;string&gt; distinctNames = new List&lt;string&gt;(consumbleNames.Distinct()); List&lt;int&gt; quantityRelated = new List&lt;int&gt;(distinctNames.Count); for (int i = 0; i &lt; distinctNames.Count; i++) { quantityRelated.Add(new int()); for (int j = 0; j &lt; consumbleNames.Count; j++) { if (consumbleNames[j].Equals(distinctNames[i])) { quantityRelated[i] += quantity[j]; } } } foreach (int t in quantityRelated) { /* quantity corresponds to the each distinct item */ } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload