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

Sort ComboBox

C# .NET 1.1

How do I sort ComboBox in descending order?

Thanks
Peter
Feb 7 '06 #1
4 32368
I think you should sort the items before adding/binding to the
combobox. For example, you could use Array.Sort, ArrayList.Sort, or
using DataView if you are binding DataSet to the combobox. There are
also Array.Reserve and ArrayList.Reserve method for you to change the
order if neccesary.

Thi

Feb 7 '06 #2

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I think you should sort the items before adding/binding to the
combobox. For example, you could use Array.Sort, ArrayList.Sort, or
using DataView if you are binding DataSet to the combobox. There are
also Array.Reserve and ArrayList.Reserve method for you to change the
order if neccesary.

Thi


What is the best way dump the contents of the ComboBox into an ArrayList?

I have an unbound ComboBox and I want to sort this combo in either
direction.
Feb 7 '06 #3
This is the easiest way if the items implements IComparable (for
example: strings):
ArrayList list = ArrayList.Adapter(comboBox1.Items);
list.Sort();
To reverse, call list.Reverse();

Thi

Peter wrote:
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I think you should sort the items before adding/binding to the
combobox. For example, you could use Array.Sort, ArrayList.Sort, or
using DataView if you are binding DataSet to the combobox. There are
also Array.Reserve and ArrayList.Reserve method for you to change the
order if neccesary.

Thi


What is the best way dump the contents of the ComboBox into an ArrayList?

I have an unbound ComboBox and I want to sort this combo in either
direction.


Feb 7 '06 #4

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
This is the easiest way if the items implements IComparable (for
example: strings):
ArrayList list = ArrayList.Adapter(comboBox1.Items);
list.Sort();
To reverse, call list.Reverse();

Thi

Peter wrote:
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
>I think you should sort the items before adding/binding to the
> combobox. For example, you could use Array.Sort, ArrayList.Sort, or
> using DataView if you are binding DataSet to the combobox. There are
> also Array.Reserve and ArrayList.Reserve method for you to change the
> order if neccesary.
>
> Thi
>


What is the best way dump the contents of the ComboBox into an ArrayList?

I have an unbound ComboBox and I want to sort this combo in either
direction.


Thank You,

works for me.
Feb 7 '06 #5

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

Similar topics

6
by: raj | last post by:
When I try to sort my combo box I get the following error. "Cannot sort a ComboBox that has a DataSource set. Sort the data using the underlying data model." ...
2
by: MrNobody | last post by:
If I DataSource a ComboBox to a DataTable, and specify a column for ValueMember and DisplayMember, everything comes out fine until I sort. When I sort, it seems to sort the DisplayMembers...
7
by: Arnold | last post by:
Greetings Gurus, In a mainform's header, I have a combobox named comboStudents. The rowsource for this combobox is: SELECT -999 As StudentID, "<Add New Student>" As FullName, "aaa" As...
4
by: Matt | last post by:
I have been searching all over the web for a way to sort a DataGridView based on the actual text being shown in a ComboBox column as opposed to the underlying value (an ID in this case). Can anyone...
9
by: active | last post by:
Can you see why this does not sort the list? It displays OK but is not sorted Thanks for any help
1
by: Kingkev83 | last post by:
I have a problem, i use a combo box to display members details in the following format display member: (concatinated field) Surname &' '& Forename &' '& MembershipNo & - & DateofBirth as...
5
by: Nirmala123 | last post by:
hi... I want to sort the table using combobox values. I give the code here. address.html: <html> <head> <title>Add a new entry</title> </head>
15
by: Academia | last post by:
I want a string of characters that will sort after all strings of Roman letters. Something that will display using a font like the one this note is written with. Is there such a thing? I...
1
by: JAnn81 | last post by:
I have a combo box created using xaml. I bind the item source to a xml document. <Items> <Item> <Name>David</Name> <Age>20</Age> </Item> <Item> <Name>Marcus</Name> <Age>25</Age>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.