//initialize countyId combobox and city combobox public void InitializeComboBox() { ComboBoxAction.InitializeCountyComboBox(countyComboBox, cityComboBox); List <ComboBoxItem> c = new List <ComboBoxItem>(); c.Add(new ComboBoxItem("All cities", -1)); cityComboBox.DataSource = c; cityComboBox.DisplayMember = "Text"; cityComboBox.ValueMember = "Value"; cityComboBox.Visible = false; }
private void countyComboBox_SelectedIndexChanged(object sender, EventArgs e) { var countyId = (int)countyComboBox.SelectedValue; if (countyId == -1) { List <ComboBoxItem> c = new List <ComboBoxItem>(); c.Add(new ComboBoxItem("All cities", -1)); cityComboBox.DataSource = c; cityComboBox.DisplayMember = "Text"; cityComboBox.ValueMember = "Value"; cityComboBox.Visible = false; } else { ComboBoxAction.InitializeCityComboBox(countyId, cityComboBox); } DisplayHotels(Int32.Parse(pageTextBox.Text.ToString())); //set city combobox to default (all cities and show); else (hide combobox) // apelezi displayHotels // }