By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Listbox.sort Confusion

P: n/a
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

May 17 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.
"Randy" <sp***********@gmail.comwrote in message
news:11*********************@n59g2000hsh.googlegro ups.com...
>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
May 18 '07 #2

P: n/a
Thanks! That works.

Randy

May 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.