Pour savoir s'il existe deja un item portant le nom "toto" dans la première colonne d'une listview, voila le code :
Il est aussi possible de ne chercher que le début du nom, par exemple avec "to" on trouvera : "toto", "tolier", "toste" ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Dim item1 As ListViewItem = Nothing If ListView1.Items.Count > 0 Then item1 = ListView1.FindItemWithText("toto", False, 0, False) End If If (item1 Is Nothing) Then MsgBox("Ce texte n'existe pas !") End If
Références :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Dim item1 As ListViewItem = Nothing If ListView1.Items.Count > 0 Then item1 = ListView1.FindItemWithText("to", False, 0, True) End If If (item1 Is Nothing) Then MsgBox("Ce début de texte n'existe pas !") End If
http://msdn2.microsoft.com/en-us/library/y3h4x385.aspx
http://msdn2.microsoft.com/en-us/library/x03e4732.aspx
Partager