473,386 Members | 1,679 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,386 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 32374
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>
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.