|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How can I change SortedList order?I am using the SortedList class to sort an array of items. I want to bind
the SortedList to a DataGrid, but I want the list to go in descending order. Is there anyway to change the sort order in SortedList when databinding so that I can reverse the sort order? -- ----------------------------------- Ken Varn Senior Software Engineer Diebold Inc. EmailID = varnk Domain = Diebold.com ----------------------------------- There is no native method to reverse the elements in a SortedList. You can
either copy over all the elements to an ArrayList and then apply a ..Reverse() and bind to a datagrid, ORRRRRR... you can pass a class that implements IComparer in the constructor of the class which specifies how two elements should be compared and added to the list. You can find documentation on the IComparer interface here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionsicomparerclasstopic.asp HTH S.M. Altaf [MVP - VB] -------------------------------------------------------------------------------- All that glitters has a high refractive index. www.mendhak.com Show quote "Ken Varn" <nospam> wrote in message news:O$OyXf2yFHA.3000@TK2MSFTNGP12.phx.gbl... >I am using the SortedList class to sort an array of items. I want to bind > the SortedList to a DataGrid, but I want the list to go in descending > order. > Is there anyway to change the sort order in SortedList when databinding so > that I can reverse the sort order? > > > > -- > ----------------------------------- > Ken Varn > Senior Software Engineer > Diebold Inc. > > EmailID = varnk > Domain = Diebold.com > ----------------------------------- > > |
|||||||||||||||||||||||