How to Get Reference to Sender

M

Marty Cruise

I need to create a reference to the sender of an
OnMouseDown event. Here is my code:

Dim myView As New ListView
AddHandler myView.MouseDown, AddressOf viewMousedown

Sub viewMousedown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)

Dim myListView as Listview

' Now how do I get a reference to the sender so that
I can access its properties (tag, etc)?

End Sub
 
A

Armin Zingler

Marty Cruise said:
I need to create a reference to the sender of an
OnMouseDown event. Here is my code:

Dim myView As New ListView
AddHandler myView.MouseDown, AddressOf viewMousedown

Sub viewMousedown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)

Dim myListView as Listview

' Now how do I get a reference to the sender so that
I can access its properties (tag, etc)?

End Sub

mylistview = directcast(sender, listview)
 
H

Herfried K. Wagner [MVP]

Hello,

Marty Cruise said:
I need to create a reference to the sender of an
OnMouseDown event. Here is my code:

Dim myView As New ListView
AddHandler myView.MouseDown, AddressOf viewMousedown

Sub viewMousedown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)

\\\
DirectCast(sender, ListView).<...> = <...>
///
 

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