public Form1() { InitializeComponent(); CountryDropDownList.DropDownStyle = ComboBoxStyle.DropDownList; CityDropDownList.DropDownStyle = ComboBoxStyle.DropDownList; weather = new WeatherService.WeatherModel(); XmlNodeList xmlNodes = weather.GetCountryAndCityData().GetElementsByTagName("Country"); List<string> countryList = new List<string>(); foreach (XmlNode node in xmlNodes) { if (!countryList.Contains(node.InnerText)) { //Loop through the country names and put them in to a list object countryList.Add(node.InnerText); } } countryList.Sort(); //Bind the CountryDropDownList control. this.CountryDropDownList.DataSource = countryList; }
public Form1() { InitializeComponent(); CountryDropDownList.DropDownStyle = ComboBoxStyle.DropDownList; CityDropDownList.DropDownStyle = ComboBoxStyle.DropDownList; weather = new WeatherService.WeatherModel(); XmlNodeList xmlNodes = weather.GetCountryAndCityData().GetElementsByTagName("Country"); List <string> countryList = new List <string>(); foreach (XmlNode node in xmlNodes) { if (!countryList.Contains(node.InnerText)) { //Loop through the country names and put them in to a list object countryList.Add(node.InnerText); } } countryList.Sort(); //Bind the CountryDropDownList control. this.CountryDropDownList.DataSource = countryList; }