Arraylist Sort Problem for Cultures

R

Robert Bevington

Hi everyone,

I'm trying to create two listboxes that are filled with all the culture languages. This work's fine until I try to sort the listbox. If I set the listbox property Sort to true, the list is displayed alphabetically sorted. But when I select an item, the actual value points to a different language. I think the indexes are getting mixed up somehow.

So instead of sorting the listbox and thought I could sort the arraylist that I create in a separate class. However this throws an exception that two elements could not be compared.

For Each ParticularCulture As CultureInfo In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
With ParticularCulture
prvSourceLangItems.Add(New LanguageItem(.DisplayName, .Name, .LCID))
prvTargetLangItems.Add(New LanguageItem(.DisplayName, .Name, .LCID))
End With
Next

prvSourceLangItems.Sort() 'Exception thrown here.

Anyone got any ideas how I can solve this problem?

Best regards,

Robert Bevington
 
R

Robert Bevington

It seems that my problem is caused by the arraylist having more than one element. If I just add the LCID as follows:

prvSourceLangItems.Add(.LCID)
The sort now works fine. Is it not possible to sort multi-element arraylists?

Thanks for any help

Robert bevington

Hi everyone,

I'm trying to create two listboxes that are filled with all the culture languages. This work's fine until I try to sort the listbox. If I set the listbox property Sort to true, the list is displayed alphabetically sorted. But when I select an item, the actual value points to a different language. I think the indexes are getting mixed up somehow.

So instead of sorting the listbox and thought I could sort the arraylist that I create in a separate class. However this throws an exception that two elements could not be compared.

For Each ParticularCulture As CultureInfo In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
With ParticularCulture
prvSourceLangItems.Add(New LanguageItem(.DisplayName, .Name, ..LCID))
prvTargetLangItems.Add(New LanguageItem(.DisplayName, .Name, ..LCID))
End With
Next

prvSourceLangItems.Sort() 'Exception thrown here.

Anyone got any ideas how I can solve this problem?

Best regards,

Robert Bevington
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top