【问题标题】:prevent checking same item from multiple checkedlistbox in vb.net防止从 vb.net 中的多个选中列表框中检查相同的项目
【发布时间】:2014-10-29 11:03:10
【问题描述】:

如果我有 2 个选中列表框,每个都有相同的项目,例如:苹果、香蕉。如何防止用户从两个选中列表框中检查相同的项目。案例:用户无法检查苹果和苹果(来自checkedlistbox1 和checkedlistbox2)。谢谢..

【问题讨论】:

    标签: vb.net checkedlistbox


    【解决方案1】:

    我建议您检查按钮单击时的复选框列表以检查“检查两个已选中列表框中的相同项目是否已选中”的代码

      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i As Integer = 0 To CheckedListBox1.Items.Count - 1
            If CheckedListBox1.GetItemChecked(i) = True And CheckedListBox2.GetItemChecked(i) = True Then
                MsgBox("checking same item from both checkedlistbox are not allowed")
            End If
        Next
      End Sub
    

    【讨论】:

    • 感谢您的帮助,先生。我只是在其他网站上寻找解决方案,我认为您的解决方案比我现在拥有的更简单..If CheckedListBox1.CheckedItems.Contains("Apple") And CheckedListBox2.CheckedItems.Contains("Apple") Then Dim msgc1 = "Dont choose same item from AVOID and MUST list" MsgBox(msgc1) Else
    猜你喜欢
    • 1970-01-01
    • 2013-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多