views:

23

answers:

1

Hi, I want to sort the elements in C# listbox by some field in the object element.

Is there a method in C# that perform this task? Maybe a function that receives a comparison function as a parameter or something like that?

another thing, when the listbox is sorted I want to add an element to a sorted list. is there such a method?

thanks

+1  A: 

I would suggest using classical winforms binding to a System.Collections.SortedList.List<TKey,TValue> . All of the sorting will be done for you by the list, and most of the data transactions to and from the ListBox control will be done for you by the binding framework.

Reinderien
"and most of the data transactions to and from the ListBox control will be done for you by the binding framework" - which binding framework?
Day_Dreamer
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.databindings.aspx etc.
Reinderien