bonjour a tous
j ai un flowlayoutpanel ou je créer des picturebox j ai pas de probleme pour créer des evenement directe ( 1 click = je deplace , double click je l affiche dans une picturebox plus grande .....)
mais avec un contextmenustrip je peut plus rien faire car le contrôle sur lequel je pointe n est pas retourner il me retourne toujours le flowlayoutpanel ou la derniere picturebox
j espere etre assez clair
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
 
 
 Private Sub AddImageRecherche(ByVal filepath As String)
        'create and configure a Picturebox to display given image path and add it to FlowLayoutPanel
        Dim p As New PictureBox
        p.ImageLocation = filepath
        p.Size = sizes(boxsize.small)
        p.SizeMode = PictureBoxSizeMode.Zoom
        p.Tag = p.ImageLocation
 
 
        ' AddHandler p.MouseEnter, AddressOf pb_MouseEnterRecherche
        ' AddHandler p.DragLeave, AddressOf pb_MouseDragleaveRecherche
        AddHandler p.MouseDown, AddressOf childs_MouseDown
        '  AddHandler p.Click, AddressOf Control_Click
        ' AddHandler p.MouseDoubleClick, AddressOf pb_MouseDoubleClickRecherche
        AddHandler p.MouseEnter, AddressOf EnterControl_Click
        AddHandler p.MouseLeave, AddressOf LeaveControl_Click
        AddHandler p.PreviewKeyDown, AddressOf Controlefface_Click
        ' AddHandler p.MouseClick, AddressOf Control_Click
        p.ContextMenuStrip = ContextMenuLayoutRecherche
 
 
        FlowLayoutPanelRecherche.Controls.Add(p)
    End Sub
 
 Private Sub childs_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Button = Windows.Forms.MouseButtons.Left Then
            If e.Clicks = 1 Then
                Dim source As Control = CType(sender, Control)
                Using bmp As New Bitmap(source.Width, source.Height)
                    source.DrawToBitmap(bmp, New System.Drawing.Rectangle(Point.Empty, source.Size))
                    Me.dragcursor = New Cursor(bmp.GetHicon)
                End Using
                Me.dragtype = source.GetType
                Me.FlowLayoutPanelRecherche.DoDragDrop(source, DragDropEffects.Move)
                Me.dragcursor.Dispose()
            Else
                If Application.OpenForms().OfType(Of ImageView).Any Then
                    Dim p As PictureBox = sender
                    p.BackColor = SystemColors.GradientActiveCaption
                    Dim iff As New FileInfo(p.ImageLocation)
                    Dim i As String = iff.Name
                    Dim t As String = iff.FullName
                    Dim ii As String = System.IO.Path.GetFileNameWithoutExtension(i)
                    Dim PathFichierimageRechercheVehicule As String = Application.StartupPath & "\DossierVehicule\" & Trim(MarqueComboRecherche.Text) & "\" & Trim(ModeleComboRecherche.Text) & "\" & Trim(VersionCompleteComboRecherche.Text) & "\" & ii & ".png"
 
                    ImageView.PictureBoxFullView.Image = System.Drawing.Image.FromFile(PathFichierimageRechercheVehicule)
                Else
                    ImageView.Show()
 
                    Dim p As PictureBox = sender
                    p.BackColor = SystemColors.GradientActiveCaption
                    Dim iff As New FileInfo(p.ImageLocation)
                    Dim i As String = iff.Name
                    Dim t As String = iff.FullName
                    Dim ii As String = System.IO.Path.GetFileNameWithoutExtension(i)
                    Dim PathFichierimageRechercheVehicule As String = Application.StartupPath & "\DossierVehicule\" & Trim(MarqueComboRecherche.Text) & "\" & Trim(ModeleComboRecherche.Text) & "\" & Trim(VersionCompleteComboRecherche.Text) & "\" & ii & ".png"
 
                    ImageView.PictureBoxFullView.Image = System.Drawing.Image.FromFile(PathFichierimageRechercheVehicule)
                End If
            End If
 
        ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
 
        End If
 
 
    End Sub

voila mon probleme c est cast invalide type toolstrip en type picturebox