I have a bindinglist of keyvaluepairs that is filled dynamicaly.
BindingList<KeyValuePair<int, string>> Homelist = new BindingList<KeyValuePair<int, string>>();
foreach (ListItem item in listBox2.Items)
{
Homelist.Add(new KeyValuePair<int, string>(item.Id, item.Name));
}
The list has key(id) and value(name). I want to sort the first 5 items asc and then the rest items also asc.the sorting must be by value and not by key. example: if I have the values : 4,5,8,7,6,10,9,3,2,1,22 the sorting result must be 4,5,6,7,8 ,1,2,3,9,10,22.Any suggestions?
I use this to split in two lists
List<BindingList<KeyValuePair<int, string>>> listOfLists = new List<BindingList<KeyValuePair<int, string>>>();
for (int i = 0; i < Homelist.Count(); i += 5)
{
listOfLists.Add(Homelist.Skip(i).Take(5));
}
but I take the error:
cannot convert from 'System.Collections.Generic.IEnumerable<system.collections.generic.keyvaluepair><int,string>>' to 'System.ComponentModel.BindingList<system.collections.generic.keyvaluepair><int,string>>'