private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { Eten selected = (Eten)listBox1.SelectedItem; if (listBox1.DataSource != null) { label1.Text = selected.Beschrijf(); } else { label1.Text = ""; } }
private void Form1_Load(object sender, EventArgs e) { Eten eten = new Eten("Apple", "Red", new List <string>() { "Potassium", "carbohydrate" }); Eten vlees = new Vlees("Chicken", "white", "Whey"); Eten vlees2 = new Vlees("Lamb", "Red", new List <string>() { "Potassium", "Protein" }, "whey isolaat"); Eten vegetarisch = new Vegetarisch("Paprika", "Geel", "C"); Eten vegetarisch2 = new Vegetarisch("Tomato", "Red", "C"); Eten groenten = new Groenten("Wortels", "oranje", new List <string>() { "Potassium", "sodium" }, "A", "Sulfur"); Eten groenten2 = new Groenten("Courgette", "Groen", new List <string>() { "¨Phosphorus" }, "B", "Magnesium"); Eten fruit = new Fruit("Mango", "Geel", new List <string>() { "Chloride" }, "C", 50.00); Eten fruit2 = new Fruit("Bananan", "Geel", new List <string>() { "Potassium" }, "B", 20.00); comboBox1.Items.Add("Eten"); comboBox1.Items.Add("Vegetarisch"); comboBox1.Items.Add("Vlees"); food.Add(vlees); food.Add(vlees2); food.Add(vegetarisch); food.Add(vegetarisch2); food.Add(groenten); food.Add(groenten2); food.Add(fruit); food.Add(fruit2); }