Attaching Multiple Delegate for Single Event

Chikul
Posted by Chikul under Windows Forms category on | Views : 2138
'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

Comments or Responses

Login to post response