如我有两个textbox,按一个command向listview提交数据,如何提交时限制重复项提交。请各位大侠帮忙,谢谢

解决方案 »

  1.   

    提交时,对2个TEXTBOX的数据进行筛选,然后插入
      

  2.   

    参考这个帖子的内容:
    http://topic.csdn.net/u/20101116/09/b799f0bb-d27e-4da2-8fa9-46982462a8fe.html
      

  3.   

    Private Sub Command1_Click()
        Dim i As Long
        Dim blnHave As Boolean
        
        blnHave = False
        
        For i = 1 To ListView1.ListItems.Count
            If Text1.Text = ListView1.ListItems(i) Then
                blnHave = True
                Exit For
            End If
        Next i
        
        If Not blnHave Then
            ListView1.ListItems.Add , , Text1.Text
        End If
        
        blnHave = False
        
        For i = 1 To ListView1.ListItems.Count
            If Text2.Text = ListView1.ListItems(i) Then
                blnHave = True
                Exit For
            End If
        Next i
        
        If Not blnHave Then
            ListView1.ListItems.Add , , Text2.Text
        End If
        
    End Sub
      

  4.   

    Private Sub Command1_Click()
        Dim i As Long
        Dim blnHave As Boolean
        
        '关于text1
        blnHave = False
        '先遍历判断
        For i = 1 To ListView1.ListItems.Count
            If Text1.Text = ListView1.ListItems(i) Then
                blnHave = True
                Exit For
            End If
        Next i
        '没有则添加
        If Not blnHave Then
            ListView1.ListItems.Add , , Text1.Text
        End If
        
        '关于text2
        blnHave = False
        '先遍历判断
        For i = 1 To ListView1.ListItems.Count
            If Text2.Text = ListView1.ListItems(i) Then
                blnHave = True
                Exit For
            End If
        Next i
        '没有则添加
        If Not blnHave Then
            ListView1.ListItems.Add , , Text2.Text
        End If
        
    End Sub
      

  5.   

    限制重复项,应该把楼上的代码
    放在listview的change事件里。