Event Handler
Roberto Marra
Hi everybody,I was checking your sample in the folder /Demo Code/COR_Events/COR_Events.cs.
For me is pretty clear this statements
btn.AddHandler_ItemPressed(ModeComponent.FormModes.ALL, ButtonClickedBefore, ButtonClickedAfter);
where you handle the ItemPressed with two handled "ButtonClickedBefore" and "ButtonClickedAfter", what is less clear is when on the close event of the form you use these whay to handle it
frm.AddHandler_Close(ModeComponent.FormModes.ALL, delegate(FormClose e) { frm.RemoveAllHandlers(); });
I don't get why you use a delegate instead of using the "usual way".
Hope I was clear in my question, by the way Im not profi on C# I just started 2 weeks ago...
Cheers
Roberto
Marco Schweighauser
Hello Roberto,it is just the short way for event handlers. We use this if the event can be handled by just one or two lines of code.
The code will become a lot easier to read if you do this for a single and small statement instead of having a complete method.
Please take a look at the following Microsoft article: http://msdn.microsoft.com/en-us/library/0yw3tz5k(VS.80).aspx
Regards,
Marco
Roberto Marra
Thnx Marco, now is very clear.Rgds
Roberto
0
Please sign in to leave a comment.
Comments
0 comments