Wednesday, February 23, 2011

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);
            
            }
        }

SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...