Image

Bonjour,

j'aimerais savoir, s'il est possible d'inserer des image dans une listview?

merci,

bonjour

oui;il est possible

cdt


Private Sub UserForm_Initialize()
    Set f = Sheets("bd")
    Me.ImageList1.ImageHeight = 60
    Me.ImageList1.ImageWidth = 60 / 1.2
    répertoirePhoto = ThisWorkbook.Path & "\"   ' adapter
    With Me.ListView1
        With .ColumnHeaders
            .Clear
            .Add , , "Nom", 80
        End With
        ligne = 1
        .Gridlines = True
        .View = lvwReport
        For Each c In f.Range("A2:A" & f.[a65000].End(xlUp).Row)
           .ListItems.Add , , c
            If Dir(répertoirePhoto & c & ".jpg") <> "" Then
              Me.ImageList1.ListImages.Add , "Img" & ligne, LoadPicture(répertoirePhoto & c & ".jpg")
              Set Me.ListView1.SmallIcons = Me.ImageList1
              Me.ListView1.ListItems(ligne).SmallIcon = "Img" & ligne
             End If
           ligne = ligne + 1
        Next c
    End With
End Sub
Private Sub ListView1_Click()
  nom = Me.ListView1.SelectedItem
  ActiveCell = nom
  For Each s In ActiveSheet.Shapes
    If s.Type = 13 Then
      If s.TopLeftCell.Address = ActiveCell.Offset(0, 1).Address Then s.Delete
    End If
  Next s
  répertoirePhoto = ThisWorkbook.Path & "\"
  Set img = ActiveSheet.Pictures.Insert(répertoirePhoto & nom & ".jpg")
  img.Left = ActiveCell.Offset(, 1).Left + 1
  img.Top = ActiveCell.Offset(, 1).Top + 1
  ech = 0.75
  img.Height = img.Height * ech
  img.Width = img.Width * ech
End Sub

ok , Je test ta macro et je reviendrais vers toi si j'ai des questions

Rechercher des sujets similaires à "image"