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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
Public Sub RemplirListView(MaListview As ListView, Optional NomLigne As String, Optional NomColonne As String)
Dim I As Long
Dim j As Long
Dim Itmx As ListItem
With MaListview
.FullRowSelect = True
.GridLines = False
.HideSelection = False
.LabelEdit = lvwManual
.MultiSelect = False
.AllowColumnReorder = False
.ListItems.Clear
.ColumnHeaders.Clear
.Visible = False
End With
If rsADO.Fields.Count > 0 Then
If MaListview.Tag > 0 Then
MaListview.ColumnHeaders.Add , , NomLigne & "/" & NomColonne
I = 1
MaListview.GridLines = True
Else
I = 0
End If
For N = I To rsADO.Fields.Count - 1
MaListview.ColumnHeaders.Add , , rsADO.Fields(N).Name
Next N
If rsADO.RecordCount > 0 Then
While Not rsADO.EOF
Set Itmx = MaListview.ListItems.Add(, , CStr(rsADO.Fields(0).Value))
For j = 1 To rsADO.Fields.Count - 1
Itmx.SubItems(j) = IIf(LenB(rsADO.Fields(j).Value) > 0, rsADO.Fields(j).Value, vbNullString)
DoEvents
Next j
rsADO.MoveNext
Wend
On Error GoTo Err
End If
End If
MaListview.Visible = True
Exit Sub
Err:
MsgBox ("Erreur: Impossible de charger les données")
End Sub |
Partager