private void metroComboBox1_SelectedIndexChanged(object sender, EventArgs e) { SubCategoryRepository subCategoryRepository = new SubCategoryRepository(); var list = subCategoryRepository.SubCategoryList(Convert.ToInt32(metroComboBox1.SelectedValue.ToString())); list.Insert(0, new SubCategory() { SubCategoryName = "-Select-" }); var source = new BindingSource(); source.DataSource = list; metroComboBox2.ValueMember = "Id"; metroComboBox2.DisplayMember = "SubCategoryName"; metroComboBox2.DataSource = source; metroComboBox2.SelectedIndex = 0; }
private void GetSubCategories() { var selected_category = Convert.ToInt32(cb_category.SelectedValue.ToString()); SubCategoryRepository subCategoryRepository = new SubCategoryRepository(); var list = subCategoryRepository.SubCategoryList(selected_category); list.Insert(0, new SubCategory() { SubCategoryName = "-Select-" }); var source = new BindingSource(); source.DataSource = list; cb_sub_category.DisplayMember = "SubCategoryName"; cb_sub_category.ValueMember = "Id"; cb_sub_category.DataSource = source; cb_sub_category.SelectedIndex = 0; }