Bonjour

Voilà, j'aimerais remplir une listview2, soit en cochant une checkbox, soit en Dblclik sur la ligne d'une Listview1, mais je ne connais pas du tout la démarche pour remplir cette seconde listview. Voilà ce que j'ai pour l'instant.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Private Sub UserForm_initialize()
 
' Dim hwnd As Long, exLong As Long, zFactor As Integer
 ' hwnd = FindWindowA(vbNullString, Me.Caption)
 ' exLong = GetWindowLongA(hwnd, -16)
 ' If exLong And &H880000 Then SetWindowLongA hwnd, -16, exLong And &HFF77FFFF
 ' zFactor = 100 * CInt(Application.Width / Me.Width)
 ' Me.Width = Application.Width
 ' Me.Height = Application.Height
'                'Dim hwnd As Long
 ' hwnd = FindWindowA("Thunder" & IIf(Application.version Like "8*", "X", "D") & "Frame", Me.Caption)
 ' SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
 
Dim t As Byte, x As Byte, j As Byte
Dim c As Range
 
 
'''''''''''''''''''''''Code pour couleur listview
Dim i&: i = (ListView1.Width * 1 / 3) - 6 & (ListView2.Width * 1 / 3) - 6
hwnd = GetWindow(FindWindow(vbNullString, Me.Caption), 5)
With ListView1
.View = lvwReport
.FullRowSelect = True
End With
hFont = CreateFont(13, 0, 0, 0, 700, 0, 0, 0, 0, 0, 0, 0, 0, "Cambria")
OldProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WinProc)
 
''''''''''''''''''''''''''''''''''''
 
'on remplit les entetes de colonnes de la listview
With ListView1
        With .ColumnHeaders
            .Clear 'Supprime les anciens entêtes
 
            'Ajout des colonnes
            .Add , , "Désignation Matériel", 140, lvwColumnLeft 'obligatoire alignement a droite premiere colonne
            .Add , , "Nom", 140, lvwColumnCenter
            .Add , , "Type", 60, lvwColumnCenter
            .Add , , "Marque", 60, lvwColumnCenter
            .Add , , "Taille", 50, lvwColumnCenter
       End With
 
    .View = lvwReport 'affichage en mode Rapport
    .Gridlines = True 'affichage d'un quadrillage
    .FullRowSelect = True 'Sélection des lignes comlètes
 
 For i = 3 To Sheets("Matériel").Range("A65536").End(xlUp).Row
.ListItems.Add , , Sheets("Matériel").Cells(i, 1) 'référence
.ListItems(.ListItems.Count).ListSubItems.Add , , Sheets("Matériel").Cells(i, 2) 'désignation
.ListItems(.ListItems.Count).ListSubItems.Add , , Sheets("Matériel").Cells(i, 3) 'qté en stock
.ListItems(.ListItems.Count).ListSubItems.Add , , Sheets("Matériel").Cells(i, 4) ', "## ##0.00 €") 'PVHT
.ListItems(.ListItems.Count).ListSubItems.Add , , Sheets("Matériel").Cells(i, 5) 'durée
.ListItems(.ListItems.Count).ListSubItems.Add , , Sheets("Matériel").Cells(i, 6) ', "# ##0.000") 'poids MA
 
 '==========Mise en forme de la troisième colonne première exclus (3)==========
 'If Sheets("Matériel").Cells(i, 16) > 0 Then
    .ListItems(.ListItems.Count).ListSubItems(1).ForeColor = &H4040
     'Else
    .ListItems(.ListItems.Count).ListSubItems(1).ForeColor = &HFF
    .ListItems(.ListItems.Count).ListSubItems(1).Bold = True
   ' End If:
Next: End With
 
End Sub
 
Private Sub ListView1_Click()
 
Dim t As Byte, x As Byte, j As Byte
Dim c As Range
 
ListView2.Visible = True
'on remplit les entetes de colonnes de la listview
With ListView2
        With .ColumnHeaders
            .Clear 'Supprime les anciens entêtes
 
            'Ajout des colonnes
            .Add , , "Désignation Matériel", 140, lvwColumnLeft 'obligatoire alignement a droite premiere colonne
            .Add , , "Nom", 140, lvwColumnCenter
            .Add , , "Type", 60, lvwColumnCenter
            .Add , , "Marque", 60, lvwColumnCenter
            .Add , , "Taille", 50, lvwColumnCenter
       End With
 
    .View = lvwReport 'affichage en mode Rapport
    .Gridlines = True 'affichage d'un quadrillage
    .FullRowSelect = True 'Sélection des lignes comlètes
 End With
 End Sub
Merci a vous