I have two comboboxes. When I change value of category combobox, it should automatically change value of size combobox.
private void New_Item_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'pitauzDBDataSet.Item' table. You can move, or remove it, as needed.
this.itemTableAdapter.Fill(this.pitauzDBDataSet.Item);
cbx_product_category.Items.Add("Pita");
cbx_product_category.Items.Add("Drinks");
cbx_product_category.Items.Add("Other Foods");
}
private void cbx_product_category_SelectedIndexChanged(object sender, EventArgs e)
{
string ItemSelected = cbx_product_category.SelectedIndex.ToString();
if(ItemSelected == "Pita")
{
cbx_product_size.Items.Clear();
cbx_product_size.Items.Add("Small");
cbx_product_size.Items.Add("Regular");
cbx_product_size.Items.Add("Large");
cbx_product_size.Items.Add("Very-Large");
}
if(ItemSelected == "Drinks")
{
cbx_product_size.Items.Clear();
cbx_product_size.Items.Add("0.5L");
cbx_product_size.Items.Add("1L");
cbx_product_size.Items.Add("1.5L");
}
if (ItemSelected == "Other Foods")
{
cbx_product_size.Items.Clear();
cbx_product_size.Items.Add("Half");
cbx_product_size.Items.Add("Full");
}
}
It is not giving any error. Just logic not working.
Aucun commentaire:
Enregistrer un commentaire