Imports System.Collections.Generic
Imports System.Globalization
Public Sub ListCountries(SourceCombo As System.Windows.Forms.ComboBox)
' Iterate the Framework Cultures...
For Each ci As CultureInfo In CultureInfo.GetCultures(CultureTypes.AllCultures)
Dim ri As RegionInfo
Try
ri = New RegionInfo(ci.Name)
Catch
'If a RegionInfo object could not be created don't use the CultureInfo for the country list.
Continue For
End Try
' Create new country dictionary entry.
Dim newKeyValuePair As New KeyValuePair(Of String, String)(ri.EnglishName, ri.ThreeLetterISORegionName)
' If the country is not already in the countryList add it...
If Not countryList.ContainsKey(ri.EnglishName) Then
countryList.Add(newKeyValuePair.Key, newKeyValuePair.Value)
SourceCombo.Items.Add(ri.EnglishName)
End If
Next
SourceCombo.Sorted = True
End Sub
I added three combo boxes to a form and called the above function three times for each combo boxes in the form load event. like: listcountries(ComboBox1) listcountries(ComboBox2) listcountries(ComboBox3)
but the first combobox only lists all countries and the other two are empty. please help me how to solve this.
im using vb.net 12 ultimate & windows 7
thank you