Reputation: 883
my input
Sore | aye
A | 1
A | 2
A | 3
B | 1
B | 2
OutPut: and I want to sort the top table into the underneath treeview
A
1
2
3
B
1
2
Upvotes: 1
Views: 124
Reputation: 4012
lets assume you have class called Table
containing two properties list<string> Sore
and List<int> aye
public class Table
{
public String Sore { get; set; }
public int Aye { get; set; }
}
var table = new List<Table>
{
new Table{ Sore = "A" , Aye = 1},
new Table{ Sore = "A" , Aye = 2},
new Table{ Sore = "A" , Aye = 3},
new Table{ Sore = "B" , Aye = 1},
new Table{ Sore = "B" , Aye = 2},
};
var group = table.GroupBy(q => q.Sore).ToList();
foreach (var g in group)
{
Debug.WriteLine(g.Key);
foreach (var i in g)
{
Debug.WriteLine(" "+i.Aye);
}
}
the Output will be:
A
1
2
3
B
1
2
Upvotes: 3