What you need to do is group the data on ListA
.
var groups = giveData.GroupBy(state => state.ListA);
foreach(var group in groups)
{
//add header to treeview
string header = group.Key;
foreach(var state in group)
{
//add this state as a child of the group you just added
}
}
I'd also suggest creating a lookup to help you map the ListA
number to it's textual representation:
var headerLookup = new Dictionary<string, string>()
{
{"1", "Header One"},
{"2", "Header Two"},
{"3", "Header Three"}
};
This will allow you to do the following:
string headerText = headerLookup[group.Key];