Vb.Net to C# : Same event code for Multiple controls

Hi

Following Vb.net code handles ItemDrag events for
the ListView controls lvw1, lvw2, lvw3 and lvw4

Private Sub ListView_ItemDrag(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles lvw1.ItemDrag, lvw2.ItemDrag, lvw3.ItemDrag, lvw4.ItemDrag
      sender.SelectedItems(0).Text = "Event Triggered"
End Sub

How to do the same in C# ?

Thanks
Shiju
LVL 14
Shiju SasidharanAssoc Project ManagerAsked:
Who is Participating?
 
Bob LearnedCommented:
Try this:

      this.lvw1.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.ListView_ItemDrag);
      this.lvw2.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.ListView_ItemDrag);
      this.lvw3.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.ListView_ItemDrag);

private void ListView_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e)
{
     ((ListView)sender).SelectedItems(0).Text = "Event Triggered";
}

Bob
0
 
Shiju SasidharanAssoc Project ManagerAuthor Commented:
Thank u Bob

That was fine :-)
Thank u

Shiju
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.