Control comboboxes in groupboxes

37 views Asked by At

I have 56 comboboxes in 8 groupboxes.Groupboxes' name is groupBox1 , groupBox2 so on.Checboxes' name is comboBox_51, comboBox_52..comboBox_530 , comboBox_71... comboBox_725 so on.I want to control start names comboBox_5 and comboBox_7 and get information about selectedIndex here is my code which is unsuccess.

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;
                }
            }

        }
0

There are 0 answers