[VB.net] MouseHover et MouseLeave dans PictureBox Générer automatiquement
Bonjours,
Je ne sais pas comment faire pour dissocier les PictureBox, seul la derniere PictureBox generer fait se que l'on luis demande .
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Opacity = 0.5
users = ("C:\Users\Bryan\Desktop\ModdingDesign\Dock_Gamer\Users\")
For Each Fichier In IO.Directory.GetDirectories(users)
Dim info As New IO.DirectoryInfo(Fichier)
nom = info.Name
Pics = New PictureBox
Texte = New Label
Dim chemin = (users & nom)
Dim exe As New IO.StreamReader(chemin & "\chemin.txt")
Dim exesave = exe.ReadLine()
exe.Close()
With Pics
.Size = New Size(100, 150)
.ImageLocation = (users & nom & "\pochette.jpeg")
.SizeMode = PictureBoxSizeMode.StretchImage
.Tag = exesave
.Name = nom
AddHandler .Click, AddressOf PictureBox_Click
AddHandler .MouseHover, AddressOf PictureBox_MouseHover
AddHandler .MouseLeave, AddressOf PictureBox_MouseLeave
End With
With Texte
.Text = nom
End With
With FlowLayoutPanel2
.Controls.Add(Texte)
.FlowDirection = FlowDirection.LeftToRight
End With
With FlowLayoutPanel1
.FlowDirection = FlowDirection.LeftToRight
.Controls.Add(Pics)
.Controls.Add(FlowLayoutPanel2)
End With
Next Fichier
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
Private Sub PictureBox_MouseHover(sender As Object, e As EventArgs)
With Pics
.Size = New Size(200, 300)
End With
End Sub
Private Sub PictureBox_MouseLeave(sender As Object, e As EventArgs)
With Pics
.Size = New Size(100, 150)
End With
End Sub
Private Sub PictureBox_Click(sender As Object, e As EventArgs)
Dim strFileName As String = DirectCast(sender, PictureBox).Tag.ToString
Process.Start(strFileName)
End Sub |