简体   繁体   中英

How to checked Index of Checkedlistbox2 if index of Checkedlistbox1 was checked

Can anyone who can help to solve my problem? I'm trying to checked index of Checkedlistbox2 if index of checkedlistbox1 was checked.Currently this is my code right now on vb.net. Example: if the value of Checkedlistbox1 was a , b , c and for Checkedlistbox2 was 1 , 2 , 3 then if the Value of b at Checkedlistbox1 was checked then the value of 2 on Checkedlistbox2 was already checked.

Private Sub Checkedlistbox1_ItemCheck(sender As Object, e As ItemCheckEventArgs) Handles Checkedlistbox1.ItemCheck
    If e.NewValue = CheckState.Checked Then
        For Each i As Integer In Checkedlistbox1.CheckedIndices
            Checkedlistbox1.SetItemChecked(i, False)
        Next
       'at this code I'll try to put those index of
       'Checkedlistbox2 was already checked, and it 
       'depends upon an index checked at Checkedlistbox1
    End If
End Sub

Try this!

Private Sub CheckedListBox1_ItemCheck(sender As Object, e As ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
    CheckedListBox2.SetItemChecked(e.Index, True)
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM