473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Listbox.sort Confusion

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
2 1896
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
Thanks! That works.

Randy

May 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jason | last post by:
Here is an odd issue. I am trying to shed some light on why this is causing a problem. I have an ArrayList. I am binding it to a ListBox control with has its Sort property set to True. If the...
8
by: Bill | last post by:
I'm trying to create a wizardlike interface using a couple listboxes. I know you've seen it before. You double click on an item in one listbox and it "moves" it to the other. I used to approach...
0
by: Ray | last post by:
Folks, I have just created a simple procedure that does the following: Determines the width of the columns of a listbox. Places a button of the correct size above each column as the form opens....
7
by: 00_ChInkPoIntD12 | last post by:
Can anyone confirm there isn't a Sort() method for WebControl Listbox in Asp.net? It is rather simple to write a method to do the sorting, but just wondering I shouldn't invent the wheel if...
1
by: JMann101 | last post by:
I am writing a ASP.NET(VB) application and am having some trouble. I have a datagrid which list users and when an admin clicks "edit" a defined column becomes visible and a dynamic listbox control...
2
by: Joe Fallon | last post by:
I have 2 listboxes on a Web Form. As I move an item from 1 to the other it shows up at the end of the list. How can I sort the list that just got the new item added to it so it is in alphabetical...
4
by: Just Me | last post by:
I populate a ListBox with Objects (not Strings) that has a String field (which is displayed) and an Integer field (which is not displayed). I need to have the displayed items in the Listbox...
10
by: ken | last post by:
Hi, Say I have a list box. I also created a control on a form bound to that list box. When I click different rows in the listbox the control changes the ID of the row depending on what I click. ...
4
by: rn5a | last post by:
Can the items in a ListBox be sorted by the name of the items? The ListBox actually lists all directories & files existing in a directory on the server. Note that all the directories should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.