I have a large WiseJ vb.net program which has multiple Picturebox controls. An image is loaded into the control on one event, the cursor changes on another etc. Each picturebox use four different events for my functionality. The first picturebox executes the events flawlessly. On the second identically specified picturebox the event handler fails to fire. It won't even execute the breakpoint. I have 8 such picture boxes but only one fires the event handler. I've searched for solutions and tried some but none really address my problem.
I had initially simply copied the working first picturebox code, pasted them, and edited the names to match the next picturebox. This has normally worked well to save time. I then deleted the second picturebox code and went to the page. I double-clicked the offending picture box which generated the click event. The new event still did not fire. I considered a solution which removed the event handler in each picturebox, but frankly, I've added events on pictureboxes so many times and they work fine. I'm guessing something is corrupted behind the scenes but in reviewing the project pages I see no reference to the pictureboxes and am not sure where to look. It's odd that one works fine with all the events but a second fails.
This even works
Private Sub PicFrontLR_Click(sender As Object, e As EventArgs) Handles PicFrontLR.Click
If SpkrDragged = False Then
Cursor = Cursors.Default
LoadSpkrinView(0, "System")
End If
End Sub
This event fails
Private Sub PicFrontC_Click(sender As Object, e As EventArgs) Handles PicFrontC.Click
If SpkrDragged = False Then
Cursor = Cursors.Default
LoadSpkrinView(1, "System")
End If
End Sub
I'm hoping I'm missing something, because one of the solutions involved recreating the page and systematically looking for a failure as I went. This page has a lot of code. Almost done with it and everything else seems to work perfectly.
Well, I figured this one out, mostly. It turns out that a picturebox "apparently" only triggers certain events if there's an image in it. Maybe basic knowledge but I hadn't run into this before. I simply added both a load picture event for the picture box and one for the container. If there's no image the container event fires. If there's an existing picture the picturebox event fires.
One unexplained issue is that the first picture box in a group of eight copied picture boxes, still fires the picturebox event even if there's no picture. As stated the picture box properties are all identical as are the containers. This is what confused me as one event worked and the others did not. Maybe someone can explain.