.net - Question about events in vb.net -


When it comes to events in vb.net, I was thinking about my options what I would like to do Tracking events that have been removed in any application, without explicitly declaring them with 'handle' everything. Here's a pseudo code:

  Private sub-handles handle all events (as the system's sub-sender, object, and system in the form of aventure). Select Event Case Sender Episode 1 Button If Event = Click Then Do Something () End if Finish Select Finish Sub  

Yes I know it is not quite working, but what Is there any way to implement something like this in vb.net? My end game really has to be able to monitor events that have been removed from other objects in many objects, is not one more worthwhile way to do this, then to add a special sub to each object that I want to catch Are you

I need to remove an object in other objects without any particular object, addHandler runs a long way, but I can not really use it dynamically: < / P>

  Public Sub AddEvent (event as event.ergroups) AddHandler Event AddressOf doSomething () and sub  

with whom will be called:

  Objec .AddEvent (form1.button1.Click)  

Do I have any type of Making sense? Do you know what I'm talking about? Do you know how to do this? Appreciate any help!

Prophecy: I do not think it's a good idea, all your events will handle me all the conditional expression I think that less IFs in a program are less for better maintenance, that means the designer has done a good job using the object-oriented paradigms, design patterns and good behavior of the design.)

< P> He said, this is a different matter when you get less code Want to eat (improves maintenance like this) and handle same events for many similar controls, which behave equally. For example, if you have a set of text boxes and you want someone with focus to make their background color more visible, then you explain the GotFocus (and the lost focus) handler code in a method.

If you still want to do this, you can use reflection to find out all the controls in your application, and for each control it can increase all the incidents, and then set handsor In its big way.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -