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

Sort a listbox by a nondisplayed object field??

P: n/a
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
Share this Question
Share on Google+
4 Replies


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

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

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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.