Action si selection d'une ligne d'une listview
Bonjour,
J'ai une list view avec plusieurs lignes et je souhaiterais qu'un graphique apparaisse, dans une zone image unique, selon la ligne sélectionnée, si ligne 1, le graphique 1 apparaisse ect.
J'ai un code qui affiche uniquement si la dernière condition est remplie, cela ne marche pas pour les lignes précédentes.
Pourriez-vous y jeter un coup d'œil?
Code:
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
| Private Sub UserForm_Initialize()
Set LeGraph1 = Sheets("Répartition financeurs").ChartObjects(1).Chart
NomImage = ThisWorkbook.Path & Application.PathSeparator & "temp1.gif"
LeGraph1.Export Filename:=NomImage, FilterName:="GIF"
Set LeGraph2 = Sheets("Répartition financeurs").ChartObjects(2).Chart
NomImage2 = ThisWorkbook.Path & Application.PathSeparator & "temp2.gif"
LeGraph2.Export Filename:=NomImage2, FilterName:="GIF"
Set LeGraph3 = Sheets("Répartition financeurs").ChartObjects(3).Chart
NomImage3 = ThisWorkbook.Path & Application.PathSeparator & "temp3.gif"
LeGraph3.Export Filename:=NomImage3, FilterName:="GIF"
End Bub
Private Sub ListView1_Click()
If ListView1.ListItems(1).Selected = True Then _
NomImage1 = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
Me.Image1.Picture = LoadPicture(NomImage1)
If ListView1.ListItems(2).Selected = True Then _
NomImage2 = ThisWorkbook.Path & Application.PathSeparator & "temp2.gif"
Me.Image1.Picture = LoadPicture(NomImage2)
If ListView1.ListItems(3).Selected = True Then _
NomImage3 = ThisWorkbook.Path & Application.PathSeparator & "temp3.gif"
Me.Image1.Picture = LoadPicture(NomImage3)
End Sub |