Jason,
As John stated, you can list multiple objects in the Handles clause or use
AddHandler.
The other thing that is useful to know is the "sender" parameter to the
event handler is the object raising the event.
For example you can use the sender to change the background color of the
panel when you are dragging over that panel, with something like:
[quoted text, click to view] > Private Sub Panel0_DragEnter(ByVal sender
> As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles
> Panel0.DragEnter, Panel1.DragEnter
If TypeOf sender Is Panel Then
Dim thePanel As Panel = DirectCast(sender, Panel)
thePanel.BackGround = Color.Red
End If
...
[quoted text, click to view] > End Sub
> Private Sub Panel0_DragLeave(ByVal sender
> As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles
> Panel0.DragLeave, Panel1.DragLeave
If TypeOf sender Is Panel Then
Dim thePanel As Panel = DirectCast(sender, Panel)
thePanel.BackGround = System.Colors.Control
End If
...
[quoted text, click to view] > End Sub
Hope this helps
Jay
"sevenfoot" <dotnetboards@sevenfoot-dot-com.no-spam.invalid> wrote in
message news:405bd20e$4_2@Usenet.com...
[quoted text, click to view] > how can I make one subroutine to handle events from different objects?
> For instance I have six panels that do the same thing when something
> is dragged into them, I'd like to have one subroutine to do this
> rather than have six.
>
> Private Sub Panel0_DragEnter(ByVal sender
> As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles
> Panel0.DragEnter
> If (e.Data.GetDataPresent(DataFormats.Text))
> Then
> e.Effect = DragDropEffects.Copy
> Else
> e.Effect = DragDropEffects.None
> End If
> End Sub
>
> Private Sub Panel1_DragEnter(ByVal sender As Object, ByVal e
> As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter
> If (e.Data.GetDataPresent(DataFormats.Text))
> Then
> e.Effect = DragDropEffects.Copy
> Else
> e.Effect = DragDropEffects.None
> End If
> End Sub
>
> here's two of the subroutines, the only thing that changes is the name
> of the panel.
>
>
> thanks,
> Jason
>
>
> Posted Via Usenet.com Premium Usenet Newsgroup Services
> ----------------------------------------------------------
> ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
> ----------------------------------------------------------
>
http://www.usenet.com