Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27192

[RESOLVED] pictureboxes and right click menu

$
0
0
We have a situation like this:

1. 4 picturebox controls
2. I want to add or remove picture from picturebux using context meny
3. Contextmenu have to be done with code (no control)

Code:

  Dim ctxmnu As New ContextMenu

        Dim item1 As New MenuItem("Add Picture")
        Dim item2 As New MenuItem("Remove")

        AddHandler item1.Click, AddressOf ContextMenuHandler
        AddHandler item2.Click, AddressOf ContextMenuHandler

        ctxmnu.MenuItems.Add(i1)
        ctxmnu.MenuItems.Add(i2)


What we have to do that our program konws which picturebox we want to fill opening fileopen dalog?


Code:

       
  Private Sub InputPicture()
        If OpenFileDialog1.ShowDialog(Me) = DialogResult.OK Then
            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
            PictureBox1.Tag = OpenFileDialog1.FileName
        Else
            OpenFileDialog1.Tag = ""
        End If
    End Sub

I've tried many things to send an argument via InputPicture() which should point to the picturebox we need but without success.

Viewing all articles
Browse latest Browse all 27192

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>