title: How can get the correct Handler of an object?
body: <p>I am making an application that requires generating panels dynamically, and in turn that each panel generated two events, one with left click and another with right mouse click.<br>
  The right click is the one that gives me trouble since I have not been able to call a Handler that I have put temporarily in the event of the left click, but now that I see that it works, I want to pass it to the ToolStripMenuItem event, but when it enters event, the sender takes ownership of the ToolStripMenuItem and in this case you would need the property "System.Windows.Forms.Panel" in order to work on the Panel object.</p>
  
  <p>I am not sure if I am doing it correctly, can you support me with any idea how to do it?</p>
  
  <p>Annex the code of what I have developed so far</p>
  
  <pre><code>Public Class Form1
  
      Dim pb, pbdoors As New Panel
  
      Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          Dim pos As Int32 = 20
          Dim contador As Int16 = 1
  
          For i As Int16 = 1 To 3
  
              Dim pb As New Panel With
              {
                  .Width = 120,
                  .Height = 460,
                  .Top = 10,
                  .Left = 10,
                  .Name = "Panel" &amp; contador,
                  .Location = New Point(pos, 20)
              }
  
              AddHandler pb.Click, AddressOf myClickHandler_b
  
              Me.Panel1.Controls.Add(pb)
  
              pb.BringToFront()
  
              pos = pos + 120
              contador = contador + 1
          Next
      End Sub
  End Class
  
  Public Sub myClickHandler_b(ByVal sender As System.Object, ByVal e As System.EventArgs)
      Dim pos As Integer = Val(TextBox38.Text)
      Dim clickedLabel As Panel = DirectCast(sender, Panel)
      clickedLabel.Location = New Point((clickedLabel.Location.X + 120), clickedLabel.Location.Y)
  
      TextBox38.Text = pos
  End Sub
  
  Private Sub ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem1.Click
      myClickHandler_b(sender, e)
  End Sub
  </code></pre>