title: Transpose a Custom Collection with Linq
body: <p>I have a BindingList of objects and each object has a nested list of items. </p>
  
  <pre><code>BindingList&lt;QuoteboardRow&gt; quoteboard = new BindingList&lt;QuoteboardRow&gt;();
  quoteboard.Add(
      new QuoteboardRow()
      {
          Product= "Cement",
          Prices = new Dictionary&lt;string, Price&gt;() {
              { "SupplierA",
                  new Price() { Low= 101, High= 102 }
              },
              { "SupplierB",
                  new Price() { Low= 101, High= 102 }
              },
              { "SupplierC",
                  new Price() { Low= 101, High= 102 }
              }
      }
  );
  dataGridView1.DataSource = quoteboard;
  </code></pre>
  
  <p>If I simply databind the collection to a datagridview, this is all I see: </p>
  
  <p><a href="https://i.stack.imgur.com/x7n8Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x7n8Q.png" alt="enter image description here"></a></p>
  
  <p>I want to try to transpose the collection, so that it has a column for each of the suppliers, and a sub-column each for the Low and High prices, respectively. Basically, like a quoteboard with a column for each supplier or if the default datagridview supports some kind of grouping: sub-columns for the low and high price for each supplier. I manually populated some datagridview cells show what I'm trying to achieve:</p>
  
  <p><a href="https://i.stack.imgur.com/NUmWj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NUmWj.png" alt="enter image description here"></a></p>
  
  <p>I've been trying to make headway with code such as this snippet below, but to no avail. </p>
  
  <pre><code>var result = quoteboard
  .SelectMany(x =&gt; x.Prices.Select((item, index) =&gt; new { Source = x.Product, item, index  }))
  .GroupBy(i =&gt; i.index)
  .Select(g =&gt; g.ToList())
  .ToList();
  </code></pre>
  
  <p>I'd appreciate any help at all with this. In case there's a better way to databind the datagridview and collection, the datagridview is read-only and I'll be updating the collection to reflect any changes in the prices. </p>