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
|
Private Sub ListView1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
'on cherche l'index dans le tablolargeur enrtegistré dans le activate l'ors de la creation
For c = 0 To 16
If x > tablolargeur(c) Then col = c
Next
ind = IIf(Val((y - 21) / 21) = 0, 1, Val((y - 20) / 21))
ind = IIf(ind > 4, 4, ind)
ListView1.ListItems(ind).Selected = True
MsgBox " vous avez cliqué sur " & ListView1.ListItems(ListView1.SelectedItem.Index).ListSubItems(col).Text
'ListView1.ListItems(1).Selected = True
End Sub
Private Sub ListView1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As stdole.OLE_YPOS_PIXELS)
For c = 0 To 16
If x > tablolargeur(c) Then col = c
Next
ind = IIf(Val((y - 21) / 21) = 0, 1, Val((y - 20) / 21))
ind = IIf(ind > 4, 4, ind)
ListView1.ListItems(ind).Selected = True
End Sub
Private Sub Worksheet_Activate()
nbcourses = 16
'----- remplissage ListView------------------------
With ListView1
ListView1.ListItems.Clear
With .ColumnHeaders
.Clear
.Add , , "reunion", 80 ' ici c'est la premiere colonne elle mesure 80
tablolargeur(0) = 80
For i = 1 To nbcourses
.Add , , "course" & i, 80 + 5 * i ' ici j'ajoute 5 multiplié par i a chaque ajout de colonne
'ce qui va nous donner une colonne de 85,90,95,100,105 etc...... OK????
tablolargeur(i) = old + 80 + 5 * i - 5
old = tablolargeur(i)
Next
Debug.Print Join(tablolargeur, ",")
End With
'on ajoute nos RX et les RxCY sur leur lignes respectives
For i = 1 To 4
.ListItems.Add , , "R" & i 'ajoute la reunion
For c = 1 To nbcourses
.ListItems(i).ListSubItems.Add , , "R" & i & "C" & c 'ajoute le RXCY
Next
Next
End With
'--------------------------------------------------
'Spécifie l'affichage en mode "Détails"
ListView1.View = lvwReport
ListView1.ListItems(1).Selected = True
End Sub |