我在8个groupbox中有56个组合框.Groupboxes的名字是groupBox1,groupBox2依此类推.Checboxes的名字是comboBox_51,comboBox_52..comboBox_530,comboBox_71 ... comboBox_725等等。我想控制起始名comboBox_5和comboBox_7和获取有关selectedIndex的信息,这是我失败的代码。
foreach (var groupbox_ in this.Controls.OfType<GroupBox>().Where(x => Name.StartsWith("groupBox")))
{
foreach (var combobox_ in this.groupbox_.Controls.OfType<ComboBox>().Where(x => Name.StartsWith("comboBox_5")))
{
switch (combobox_.SelectedIndex)
{
case 0:
toplam += 20F; akts += 5;
break;
case 1:
toplam += 17.5F; akts += 5;
break;
case 2:
toplam += 15F; akts += 5;
break;
case 3:
toplam += 12.5F; akts += 5;
break;
case 4:
toplam += 10F; akts += 5;
break;
case 5:
toplam += 7.5F; akts += 5;
break;
case 6:
toplam += 5F; akts += 5;
break;
case 7:
toplam += 2.5F; akts += 5;
break;
case 8:
toplam += 0F; akts += 5;
break;
default:
toplam += 0F; akts += 0;
break;
}
}
}