WPF Get All Country in Combobox

To Get all Country Name in your program now you no need to use Enum or load from Database. Microsoft .NET give All Country Name using this code.
** You need to use namesapce: using System.Globalization;
Create a Method in Load event of your UI and Implement it as Following:

    private void PopulateCountryComboBox()
        {
            RegionInfo country = new RegionInfo(new CultureInfo("en-US", false).LCID);
            List<string> countryNames = new List<string>();
            foreach (CultureInfo cul in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
            {
                country = new RegionInfo(new CultureInfo(cul.Name, false).LCID);

                countryNames.Add(country.DisplayName.ToString());
            }

            IEnumerable<string> nameAdded = countryNames.OrderBy(names => names).Distinct();

            foreach (string item in nameAdded)
            {
                supplierCountryComboBox.Items.Add(item);
            
            }
        }

Popular posts from this blog

WPF Crystal Report Viewer Using SAP

mvc razor textboxfor change event change another textboxfor value

ASP.NET MVC razor SAP Crystal report