System.Globalization and ComboBox of Countries
-
Hi there I understand I can create a list of countries in a combobox using System.Globalization. I haven't been able to figure out how to do it. Anybody know how?
-
Hi there I understand I can create a list of countries in a combobox using System.Globalization. I haven't been able to figure out how to do it. Anybody know how?
public static List<string> GetCountryList()
{
List<string> cultureList = new List<string>();
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
foreach (CultureInfo culture in cultures)
{
RegionInfo region = new RegionInfo(culture.LCID);
if (!(cultureList.Contains(region.EnglishName)))
cultureList.Add(region.EnglishName);
}
return cultureList;
}Then just add the list to the combobox
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.
-
public static List<string> GetCountryList()
{
List<string> cultureList = new List<string>();
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures);
foreach (CultureInfo culture in cultures)
{
RegionInfo region = new RegionInfo(culture.LCID);
if (!(cultureList.Contains(region.EnglishName)))
cultureList.Add(region.EnglishName);
}
return cultureList;
}Then just add the list to the combobox
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.
Wow. I had no idea .NET held a list of countries like that. And grrrr, they had to use the French "NativeName" for Belgium. So why don't they show the US in Spanish? In fact they do, if we look at all the cultures, including EnglishName duplicates. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
modified on Sunday, May 16, 2010 2:59 PM
-
Wow. I had no idea .NET held a list of countries like that. And grrrr, they had to use the French "NativeName" for Belgium. So why don't they show the US in Spanish? In fact they do, if we look at all the cultures, including EnglishName duplicates. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
modified on Sunday, May 16, 2010 2:59 PM
It's nice to know it's not just me who keeps on finding new things in .NET! :laugh:
I have learnt that you can not make someone love you, all you can do is stalk them and hope they panic and give in. Apathy Error: Don't bother striking any key.