I have two comboBox cb_Brand and cb_Model in winForm.
cb_Model populates the values ββon the Select mark. The problem is this: if we select the any brand and select any model under this brand, cb_Model will not lose the value of the previous selected model. for example: if we select the Audi brand and the A3 model and select the Ford brand, when I click on cb_Model to select a model, it displays A3 as the selected model, but still the other models in the list belong to ford.
my code is:
private void cb_Brand_SelectedIndexChanged(object sender, EventArgs e) { // Clear Current Data cb_Model.Text = ""; cb_Model.Items.Clear(); CarModel _carmodel = new CarModel (); // Get Selected Car Brnad int CarBrandID = _carmodel .GetCarBrandID(cb_Brand.Text); //Enable choice of Model SortedList<int, Model> colM; colM = Model.ReadModel(CarBrandID); cb_Model.DisplayMember = "ModelText"; foreach (Model objM in colM.Values) { cb_Model.Items.Add(objM); } }
Any idea please .. Thanks
could not find the reason, but sorting out the temp fix:
private void cb_Model_Click(object sender, EventArgs e) { cb_Model.Text = ""; }
Thanks a lot guys greetings
Scorpion
source share