Ich möchte meine ComboBox zeigen eine Reihe von Parametern jedes Mal, wenn ich etwas aus der ListBox, aber es zeigt nichts innerhalb der ComboBox.Combobox wird nicht angezeigt Items während der Auswahl des Parameters aus Listbox C#
Das ist, was ich bisher habe ...
private void Form1_Load(object sender, EventArgs e)
{
listBox4.Items.Add("BE");
listBox4.Items.Add("MBA");
listBox4.Items.Add("Pharmacy");
}
private void listBox4_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if ((string)listBox4.SelectedItem == "BE")
{
comboBox1.Items.Add("CSE");
comboBox1.Items.Add("IT");
comboBox1.Items.Add("ME");
comboBox1.Items.Add("EX");
comboBox1.Items.Add("CE");
}
if ((string)listBox4.SelectedItem == "Pharmacy")
{
comboBox1.Items.Add("Pharmaceutical Chemistry");
comboBox1.Items.Add("Pharmacology");
}
if ((string)listBox4.SelectedItem == "MBA")
{
comboBox1.Items.Add("Retail Management");
comboBox1.Items.Add("HR");
}
}
Hier ist die output
Es sieht so aus, als würden Sie 'comboBox1'-Elemente füllen, wenn die Auswahl von' comboBox1' geändert wird; Sie sollten diesen Code wahrscheinlich in den obigen Event-Handler verschieben ('listBox4_SelectIndexChanged'). Es ist jedoch ein bisschen schwierig zu sagen, wo der Fehler liegt, ohne dass die entsprechende '.Designer.cs' Datei zur Hand ist. – buygrush