Home All Groups Group Topic Archive Search About

Multiple Handles clause: which control fired the event?

Author
12 Nov 2006 12:25 AM
Dean Slindee
I have one control DoubleClick event that handles the DoubleClick events for
multiple controls.  The .Tag property contains a different string value in
each control that I would like to examine.  How can I get the .Tag property
value no matter which control was double clicked?  Reflection?

Thanks,
Dean S

Author
12 Nov 2006 5:30 AM
Spam Catcher
"Dean Slindee" <slin***@charter.net> wrote in
news:WUt5h.191$Dg6.47@newsfe02.lga:

> I have one control DoubleClick event that handles the DoubleClick
> events for multiple controls.  The .Tag property contains a different
> string value in each control that I would like to examine.  How can I
> get the .Tag property value no matter which control was double
> clicked?  Reflection?


You can retrieve the original control via the "Sender" parameter.
Author
12 Nov 2006 6:33 AM
Tom Shelton
Dean Slindee wrote:
> I have one control DoubleClick event that handles the DoubleClick events for
> multiple controls.  The .Tag property contains a different string value in
> each control that I would like to examine.  How can I get the .Tag property
> value no matter which control was double clicked?  Reflection?
>
> Thanks,
> Dean S

You don't need reflection, you can just cast the sender paramter to
control, and then you will have access to the Tag property:

Private Sub DoubleClick (ByVal sender As Object, ByVal e As EventArgs)
    Dim ctrl As Control = DirectCast (sender, Control)
    Dim stringValue As String = DirectCast (ctrl.Tag, String)

    ' Do stuff with stringValue
End Sub