|
-
May 11th, 2010, 01:00 PM
#1
[RESOLVED] First items in Listbox C#
I have a listbox of countries populated from a datasource and sorted by country name.
I would like to have my two mostly used countries, the "US" and "Canada" at the top of the list.
Is there an easy way to do this.
Thanks,
Pierre
-
May 11th, 2010, 01:35 PM
#2
Re: First items in Listbox C#
In the table, add one more column - say priority. Set it to 2 for US, 1 for canada, and 0 for all others.
Sort by priority and then by name!
-
May 11th, 2010, 03:36 PM
#3
Re: First items in Listbox C#
That's work fine, was still hoping to find a way to do it within the list box without changing the table.
-
May 11th, 2010, 09:39 PM
#4
Re: [RESOLVED] First items in Listbox C#
Then code it yourself! Append US and Canada as first two entries, and retrieve other countries from table. But in that case you would lose automatic data binding.
-
May 12th, 2010, 12:40 PM
#5
Re: [RESOLVED] First items in Listbox C#
Yes, as Ajay alludes to you can create your own Comparer class that can selectively push those two entries to the top and sort the rest by alphabet or however you like.
If you liked my post go ahead and give me an upvote so that my epee.... ahem, reputation will grow.
Yes; I have a blog too - http://the-angry-gorilla.com/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|