0

チェックリストボックスの項目と比較したい一連の文字列配列があります。2 つのチェックリストボックスがあります。すべての名前 (管理者と技術者の両方)。idari をチェックするときに、idari 文字列配列にある名前だけをチェックしたい。同じことが teknik と tumu にも当てはまる。これは私のコードですが、チェックし続けます。 idari をチェックすると、すべての項目が表示されます。私のコードの何が問題なのか誰か教えてもらえますか?

    string[] tumu = { "Jane", "Tom", "Danny", "John", "Jacyln", "Lily", "Lale" };
    string[] idari = { "Jane", "Tom", "Danny" };
    string[] teknik = {  "John", "Jacyln", "Lily", "Lale"};

    private void idari_secimi()
    { //function 


        if (chklstbx_bolum.GetItemChecked(1) == false)//if the idari check box has been checked in the checked list box
        {


                for (int i = 0; i < chklstbx_sonuc.Items.Count; i++){
                    for (int j = 0; j < idari.Length; j++)
                    {

                        if (chklstbx_sonuc.SelectedItem.ToString()==idari[j])
                        {
                            chklstbx_sonuc.SetItemChecked(i, true);
                        }
                        else { }
                    }
                    }
        }
        else if (chklstbx_bolum.GetItemChecked(1) == true)
        {//unchecks all the items in the second checked list box when unchecking idari in the first checked list box.
            for (int i = 0; i < chklstbx_sonuc.Items.Count; i++)
            {
                chklstbx_sonuc.SetItemChecked(i, false);

            }
        }
    }


    private void chklstbx_bolum_ItemCheck(object sender, ItemCheckEventArgs e)
    {




        if (chklstbx_bolum.GetItemChecked(2) == false)
            tumu_secimi();
          //if the tumu box is checked call this function

        else if (chklstbx_bolum.GetItemChecked(1) == false)

            idari_secimi();
          //if the idari box is checked call this function

        else if (chklstbx_bolum.GetItemChecked(0) == false)

            teknik_secimi();
      //if the teknik box is checked call this function

}

4

1 に答える 1