Marri,
There are two kinds of sorts going on here. The first is the Sort that
the ListBox class calls. Basically, in order to use that, you will have to
clear the collection and re-add the items in the order that you want them to
be sorted in.
The other kind is the sort order that the collection has when bounded to
a data set. You can change the order in the underlying list items, but that
doesn't matter. The reason is because when bound to a data table, you are
binding to the default view on the table. Change the sort order on the
view, and you should notice that the items in the list are listed separately
(you might have to rebind).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Marri Suliez" <ma*@spam.com> wrote in message
news:Xn**********************************@24.168.1 28.86...
Has anyone found some documentation on how to properly subclass a ListBox
control and provide custom sorting (when the list items come from a
DataSource)?
The only way I can figure out how to do this is by sorting an array of
some sort and then setting the DataSource. I don't like this because it fires
the DataSourceChanged event.
What I really want to do is get access to the underlying list items, sort
them, and then have the control refresh itself. I already have access to
the underlying list items since I have set the DataSource myself. But
changing the order of the items in the DataSource does not appear to
result in the items in the control being resorted.
Any suggestions?