Ok, I have one sub and I have it handleing different events of different objects. So my problem is I want to determine which event was triggered from which object. Can anyone help me out?

I have one sub and I have it handleing different events of different objects. So my problem is I want to determine which event was triggered from which object.

Could you please post your code.

here is my subroutine:

Private Sub PictureBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox81.DragDrop, PictureBox82.DragDrop, PictureBox83.DragDrop, PictureBox84.DragDrop, PictureBox85.DragDrop, PictureBox86.DragDrop, PictureBox87.DragDrop
        'this is where my problem is, i want to know which object's event was triggered so i can change the image of it.
        {I dont know which picturebox}.Image = e.Data.GetData(DataFormats.Bitmap)
    End Sub

Ok, here's how I tested

Private Sub PictureBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.Click, PictureBox2.Click
  '
  If sender.Equals(PictureBox1) Then
    MessageBox.Show("I'm PictureBox1", "Who Am I", MessageBoxButtons.OK, MessageBoxIcon.Information)
  End If
  If sender.Equals(PictureBox2) Then
    MessageBox.Show("I'm PictureBox2", "Who Am I", MessageBoxButtons.OK, MessageBoxIcon.Information)
  End If

End Sub

And your code should go like this

Private Sub PictureBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles PictureBox1.DragDrop, PictureBox2.DragDrop
  'this is where my problem is, i want to know which object's event was triggered so i can change the image of it.
  '{I dont know which picturebox}.Image = e.Data.GetData(DataFormats.Bitmap)
  If sender.Equals(PictureBox1) Then
    PictureBox1.Image = CType(e.Data.GetData(DataFormats.Bitmap), Image)
  End If
  If sender.Equals(PictureBox2) Then
    PictureBox2.Image = CType(e.Data.GetData(DataFormats.Bitmap), Image)
  End If

End Sub

HTH

This article has been dead for over six months. Start a new discussion instead.