Multiple Handles clause: which control fired the event?

D

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
 
G

Guest

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.
 
T

Tom Shelton

Dean said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top