Listbox.sort Confusion

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

I have two listboxes on a form. The first box displays categories
while the second box displays the items belonging to the category
selected in the first box. Thus, the second box is essentially
display only. I'm trying to sort these lists alphabetically A->Z. I
have the Sort property set to True. When I run the app, the items in
each box are sorted correctly. So far, so good.

What I am confused by is that when a category is selected in the first
list box, the app treats the selection as if the box was unsorted.
For example, say that my datatable to which the listbox is bound has
rows with the pk in the order A,C,B,D. Since the listbox sort
property is set to true, the listbox presents these items in the order
A,B,C,D, as I want. If I select "B" from the listbox (*item* #2), the
app somehow thinks that I have selected "C" (*row* #2) and updates the
second listbox using "C" as the category driver. Why is this? How
can I fix it?

Any help is appreciated.
Thanks,
Randy
 
Instead of binding to a Datatable and using the Sort property of the
Listbox, you need to be binding to a sorted Dataview of of the Datatable.
 
Back
Top