.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Attaching Multiple Delegate for Single Event

Posted By:Prasanti Prusty       Posted Date: February 27, 2010    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

Attaching Multiple Delegate for Single Event
 


'Attaching Multiple Delegate for Single Event
'Here for one event (MouseDown) Both the delegates will get fire 
Public Class frmDelegates

    'First Delegate to handel the MouseDown event
    Sub frmDelegates_MouseDown1(ByVal sender As Object, ByVal e As MouseEventArgs)
        MessageBox.Show("First Delegate Executed", String.Format("the {0} Mouse Button hit me at : ", e.Button.ToString()))
    End Sub

    'Second Delegate to handel the MouseDown event
    Sub frmDelegates_MouseDown2(ByVal sender As Object, ByVal e As MouseEventArgs)
        MessageBox.Show("Second Delegate Executed", String.Format("the {0} Mouse Button hit me at : ", e.Button.ToString()))
    End Sub


    'Attach Multiple Delegate for the event
    Private Sub frmDelegates_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler Me.MouseDown, AddressOf frmDelegates_MouseDown1
        AddHandler Me.MouseDown, AddressOf frmDelegates_MouseDown2
    End Sub

End Class


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend