1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| 'Pour ajouter (ou modifier) la ListView choisie
Public Function AddList(ByVal ID As Integer, ByVal Name As String, ByVal Value As String, ByVal Unit As String, ByVal Tableau As ListView)
Dim item As ListViewItem = New ListViewItem({Addr, Name, Value, Unit})
Dim trouve As Boolean = False
'Si Invoke requis
If Tableau.InvokeRequired Then
PresenceName = Tableau.Invoke(New Func(Of String, Boolean)(Function(s As String) VerifPresenceName(s)), Name)
Debug.Print(PresenceName)
If PresenceName = False Then
'On insert les données
Tableau.Invoke(New Action(Sub() Tableau.Items.Add(item)))
Else
'On corrige les données
Tableau.Invoke(New Action(Of String, String)(Sub(s As String, i As String) CorrectionValeurName(s, i)), Name, Value)
End If
End If
Return 0
End Function
Function VerifPresenceName(ByVal s As String)
For Each ligne In TableLecture.Items
If ligne.SubItems(1).Text = s Then Return True
Next
Return False
End Function
Function CorrectionValeurName(ByVal s As String, ByVal i As String)
For Each ligne In TableLecture.Items
If ligne.SubItems(1).Text = s Then ligne.SubItems(2).Text = i
Next
Return 0
End Function |
Partager