Trapping all events
Is there anyway to trap all events to have centralized control?
Let me try to make the problem clear. Suppose I have a form and several many controls on it. As we know every control has its own events and according to certain actions(by user, system etc.), corresponding event gets fired. I am trying to centralize the event handling to handle all events of the form and its containing controls in one procedure something like:
Sub EventFired(source As Object, event As ???, args As EventArgs)
' source identifies the control say source.Name gives BtnOk, event should give the fired event, say BtnOk.Click o r just Click, args gives the arguments for the event
..... code to identify the source of event, event type and event arguments and can control whether to let the event gets fired or cancel
If (condition1) Then
args.Cancel = True ' cancels the event being fired
Can this be done? If so how? Appreciate for the ideas, comments and solutions.