Hi, I am writing some code and I need to create a context menu strip that changes it's items when is over different picture boxes, 28 to be exact.
I have tried using Addhandler but it doesn't work.
I also needed to change their size and location by using the Addhandler witch i did.
So basically if the mouse right button is pressed it changes size (this I was able to do) and if the mouse left button is pressed it should open the context menu strip(this I couldn't do).
Were is a sample of my last try:
Private Sub CCTVs_Handlers()
AddHandler CCTV1.Click, Sub(obj As Object, args As EventArgs) Drop1()
AddHandler CCTV1.DoubleClick, Sub(obj As Object, args As EventArgs) CAM1()
End sub
Private Sub Show_CCTV()
Me.Text = WText + " - CCTV"
Panel3.Show()
Panel3.Location = New Point(76, 3)
Panel3.Width = 1260
Panel3.Height = 665
Dim CCTV1 As New PictureBox
With CCTV1
.Location = New Point(0, 0)
.Width = 90
.Height = 90
.BorderStyle = BorderStyle.Fixed3D
.BackColor = Color.Green
Panel3.Controls.Add(CCTV1)
Dim lb As New Label
With lb
.Text = "CAM1"
.Location = New Point(0, 0)
CCTV1.Controls.Add(lb)
End With
End With
End Sub
Private Sub CAM1()
If CCTV1.Width = 90 Then
CCTV1.Width = 400
CCTV1.Height = 400
CCTV1.BringToFront()
Else
CCTV1.Width = 90
CCTV1.Height = 90
End If
End Sub
Private Sub Drop1()
Try
Dim CCTV1d1 As New ContextMenuStrip
With CCTV1d1
.Items.Add("Disable CAM1")
.Items.Add("Stop Recording")
.Items.Add("CAM1 Propreties")
.Items.Add("CAM1 Settings")
.Items.Add("CCTV Settings")
.DropShadowEnabled = False
.BackgroundImageLayout = False
CCTV1.ContextMenuStrip = CCTV1d1
CCTV1.Controls.Add(CCTV1d1)
End With
Catch ex As Exception
MsgBox("CCTV1d1 : " & ex.Message & " - " & ex.Source)
End Try
End Sub
What I have tried:
I have tried using Addhandler but it doesn't work
I tried to link it to other sub so it could call the context menu but this also didn't work and right now i am out of ideas
Please help