473,387 Members | 1,925 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,387 software developers and data experts.

Sort a listbox by a nondisplayed object field??

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 sorted. But sorted by the
Integer field not the displayed String.

Is there some way I can do that (in much the way a ListView can be sorted by
any column)

Thanks
Nov 21 '05 #1
4 2253
Hi,

Two ideas:

1. populate a multidimensional array or arraylist or hash table with the 2
elements (the string and the integer); when the user clicks a button, sort
as specified and repopulate the listbox.
2. if you are sorting it as part of a static listbox in a form, thus no
user interaction, you can use the idea above to sort and then populate once
in the form's load event.

HTH,

Bernie Yaeger

" Just Me" <ne********@a-znet.com> wrote in message
news:Oa*************@TK2MSFTNGP11.phx.gbl...
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 sorted. But sorted by the Integer field not the displayed String.

Is there some way I can do that (in much the way a ListView can be sorted by any column)

Thanks

Nov 21 '05 #2
Bernie, I did implement this and replied. Don't know where the reply when.

Thanks

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

Two ideas:

1. populate a multidimensional array or arraylist or hash table with the 2 elements (the string and the integer); when the user clicks a button, sort
as specified and repopulate the listbox.
Thanks, I used ArraySort to sort 2 single dimension arrays. Work good.

2. if you are sorting it as part of a static listbox in a form, thus no
user interaction, you can use the idea above to sort and then populate once in the form's load event.

HTH,

Bernie Yaeger

" Just Me" <ne********@a-znet.com> wrote in message
news:Oa*************@TK2MSFTNGP11.phx.gbl...
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 sorted. But sorted by the
Integer field not the displayed String.

Is there some way I can do that (in much the way a ListView can be

sorted by
any column)

Thanks


Nov 21 '05 #3
Hi,

No problem; glad to help.

Bernie

" Just Me" <ne********@a-znet.com> wrote in message
news:Ol**************@TK2MSFTNGP09.phx.gbl...
Bernie, I did implement this and replied. Don't know where the reply when.

Thanks

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

Two ideas:

1. populate a multidimensional array or arraylist or hash table with the
2
elements (the string and the integer); when the user clicks a button,

sort as specified and repopulate the listbox.


Thanks, I used ArraySort to sort 2 single dimension arrays. Work good.

2. if you are sorting it as part of a static listbox in a form, thus no
user interaction, you can use the idea above to sort and then populate

once
in the form's load event.

HTH,

Bernie Yaeger

" Just Me" <ne********@a-znet.com> wrote in message
news:Oa*************@TK2MSFTNGP11.phx.gbl...
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 sorted. But sorted
by the
Integer field not the displayed String.

Is there some way I can do that (in much the way a ListView can be

sorted
by
any column)

Thanks



Nov 21 '05 #4

"Bernie Yaeger" <be*****@cherwellinc.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi,

Two ideas:

1. populate a multidimensional array or arraylist or hash table with the 2 elements (the string and the integer); when the user clicks a button, sort
as specified and repopulate the listbox.

This would work for me.
2. if you are sorting it as part of a static listbox in a form, thus no
user interaction, you can use the idea above to sort and then populate once in the form's load event.

HTH,

Bernie Yaeger

" Just Me" <ne********@a-znet.com> wrote in message
news:Oa*************@TK2MSFTNGP11.phx.gbl...
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 sorted. But sorted by the
Integer field not the displayed String.

Is there some way I can do that (in much the way a ListView can be

sorted by
any column)

Thanks



Nov 21 '05 #5

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...
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....
0
by: Jason Freeman | last post by:
Hi, (Cross-posted to microsoft.public.dotnet.framework.adonet) I've got a form with a listbox and a textbox on it. Both are bound to a DataView, which is sorted on the "Name" field of the...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
1
by: Jason P Opdycke [MSFT] | last post by:
Hello All - I have 2 list boxes. Items in Left list box populated from a DB. I remove an item from the left box and add an item to the right box to allow user selection. When that item is...
4
by: Bob P. | last post by:
Hello, I have a page with: * two side-by-side asp:listboxes and two arrow asp:buttons allowing users to add/remove email addresses between them -- very much like Outlook, where you have the...
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...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
5
by: Academia | last post by:
(If you've seen this in the drawing NG, sorry. I inadvertently sent it there.) I have a listbox populated with Objects. The Class has a String field that ToString returns. I assume that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.