How can I refer to two listview controls in one event handler?

J

jmDesktop

Consider:

Private Sub ListView_ItemDrag(ByVal sender As Object, ByVal e As _
System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag, _
ListView2.ItemDrag


in VB. Can this be done in C#? I have two listview controls and want
to reference them in one statement like in VB. Thanks for any help.
 
C

Crash

Consider:

Private Sub ListView_ItemDrag(ByVal sender As Object, ByVal e As _
System.Windows.Forms.ItemDragEventArgs) Handles ListView1.ItemDrag, _
ListView2.ItemDrag

in VB. Can this be done in C#? I have two listview controls and want
to reference them in one statement like in VB. Thanks for any help.

Yes this can be done. In the += statement that adds the event handler
to the listview use the address of your shared event handler
function.

In the actual event handler function code the "sender" object will be
the desired listview control...
 

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