나는 checkedlistbox의 항목과 비교할 문자열 배열을 가지고 있습니다. 두 개의 checkedlistboxes가 있습니다. 첫 번째 상자에는 3 개의 상자가 있습니다. idari (administratives), tumu (모두) 및 teknik (기술). 두 번째 checkedlistbox 모든 이름 (둘 다 관리 및 기술)가 포함되어 있습니다. 나는 idari.And 똑같은 teknik 확인 할 때 확인해야 할 idari 문자열 배열에있는 이름 만 원한다. 그리고 tumu.This 내 코드입니다하지만 그냥 idari 체크. 모든 사람이 내 코드에 대한 잘못된 아이디어를 줄 수 있습니까? 또한 chklstbox_bolum 메서드를 호출하는 데 문제가 있어요. 당신이 다음 루프를 통해 모든 것, checkedlistbox의 항목을 문자열 배열의 항목과 비교
if (chklstbx_sonuc.SelectedItem.ToString()==idari[j])
당신이 chklstbx_sonuc에있는 항목 중 하나를 선택, 당신은 다음 bolum 목록에서 뭔가를 확인 말 :
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
} 여기
나는 그것을 시도했지만 여전히 모든 항목을 검사하고 chklstbx_sonuc는 두 번째 선택된 목록 상자이며 chklstbx_bolum은 첫 번째로 선택된 목록 상자입니다. –