VB .NET Picturebox events... frustrating :(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sgeklor
    New Member
    • Oct 2007
    • 5

    VB .NET Picturebox events... frustrating :(

    Hi Guys,

    I am trying to add some event handlers to my picturebox object which I am creating at runtime. The compiler (Visual Studio 2005) is flagging the code and telling me that the object does not have the events I am using. The code works fine for labels, just not for this picture box. Where have I gone wrong? :(

    Here is my code:

    Code:
    Dim ctrl_pb = New PictureBox
    ctrl_pb.Location = New Point(5,5)
    ctrl_pb.Visible = True
    ctrl_pb.SizeMode = PictureBoxSizeMode.AutoSize
    ctrl_pb.Name = "MyPictureBox"
    ctrl_pb.Image = MyProgram.My.Resources.ImageForPictureBox
    AddHandler (ctrl_pb.MouseEnter), AddressOf point_list_mouseover
    AddHandler (ctrl_pb.MouseLeave), AddressOf point_list_mouseout
    TargetPanel.Controls.Add(ctrl_pb)
    ctrl_pb = Nothing
    Lines #7 and #8 are the ones giving the error: "'MouseEnte r' is not an event of 'Object'." and "'MouseLeav e' is not an event of 'Object'." respectively.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Here is an article that may help:
    Class to create a picturebox with events

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      What is "TargetPane l"? Is this a web or windows application?

      I was able to create a picturebox and add events at runtime just fine?

      Comment

      Working...