Bonjour,

j'ai classer le nom des fichiers dans le m3u dans combobox1 mais j'arrive pas a afficher l'image par rapport au classement du nom dans listbox1(voir image 2).
voici en image sans image :
Nom : m3ulist.png
Affichages : 228
Taille : 12,5 Ko
en sélectionnent dans combobox1 :
Nom : Capture d’écran 2023-01-07 165516.png
Affichages : 214
Taille : 10,7 Ko

mon code :
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
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        ListBox1.Items.Clear()
        ImgList.Images.Clear()
        Dim ListImage As IEnumerable(Of ChainesData) = (From c As ChainesData In Chaines Where c.LogoURL = ComboBox1.Text Select c).Distinct.ToArray
        If ListImage.Count > 0 Then
            ImgList.Images.Add(ChargerImage(ListImage.ToString), Color.Transparent)
        Else
            ImgList.Images.Add(My.Resources.pngwing_com, Color.Transparent)
        End If
        ListBox1.Items.AddRange((From chn As ChainesData In Chaines Where chn.GroupTitle = ComboBox1.Text Select chn).Distinct.ToArray)
    End Sub
 
Private Sub ListBox1_DrawItem(sender As System.Object, e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
        e.DrawBackground()
        Dim drawDefautFont As Font = e.Font
        Dim ourFont As Boolean = False
        If (e.State And DrawItemState.Selected) = DrawItemState.Selected Then
            ourFont = True
            drawDefautFont = New Font(drawDefautFont, FontStyle.Bold)
        End If
        If e.Index <> -1 Then
            e.Graphics.DrawImage(ImgList.Images(e.Index).Clone, New Rectangle(e.Bounds.X + (ListBox1.Width / 4.4), e.Bounds.Y - 1, e.Bounds.Height, e.Bounds.Height))
            e.Graphics.DrawString(ListBox1.Items(e.Index).ToString(), drawDefautFont, New SolidBrush(e.ForeColor), e.Bounds, New StringFormat With {.Alignment = StringAlignment.Center})
        End If
        If ourFont Then drawDefautFont.Dispose()
        e.DrawFocusRectangle()
    End Sub
 
Private Function ChargerImage(ByVal Liens As String) As Image
        Dim client As New WebClient()
        Using str As Stream = client.OpenRead(Liens)
            Return Image.FromStream(str)
        End Using
    End Function
message erreur avec le code drawImage : InvalidArgument=La valeur '1' n'est pas valide pour 'index'.
Nom du paramètre : index

Pouvez-vous m'aider à afficher l'image dans listbox1 par rapport au classement dans combobox1.
Merci d'avance