1

I've a list of different sizes of a T-Shirt, e.g. S, M, L. Since this might change for T-Shirts (sometimes we just have e.g. M, L), we load this into a List sizes.

Since most DataGrids (xamDataGrid, WPF Toolkit DataGrid) need Properties for binding to the Columns, I'd like to transpose somehow my data. Does anyone have an idea how to do this?

E.g. Instead of having List where Size { string sizeName, int available, int defect, int ordered}

    Avail.  Defect Ordered
[S]   1       2       3
[M]   1       2       3
[L]   1       2       3

I want an Object which has the Properties S, M, L containing the Values like this:

         [S]    [M]     [L]
Avail.    1      2       3
Defect    1      2       3
Ordered   1      2       3

The problem here is that I don't know how many sizes will be available for the tshirt, it might be 3, 4, or 10.

Thanks for any help

Cheers

PS: Here is a mockup of how the final grid should look like http://img39.imageshack.us/img39/9161/multirowspangridfixedel.png

Joseph jun. Melettukunnel
  • 6,267
  • 20
  • 69
  • 90
  • If I'm not mistaken, DataTable already includes a transpose feature. I'm not sure, so that's why this isn't an answer. –  Oct 21 '09 at 08:58

1 Answers1

2

You should take the Transpose extension from here.

Community
  • 1
  • 1
Oliver
  • 43,366
  • 8
  • 94
  • 151
  • Is there a VB.Net version of it? cause yield keyword is not there. – Nikhil Agrawal Oct 05 '12 at 12:42
  • @NikhilAgrawal: Either take a look at [this post](http://stackoverflow.com/questions/97381/yield-in-vb-net) or put the Method in its own c# assembly. – Oliver Oct 05 '12 at 13:36