[RESOLVED] [2.0] Lack of autogenerating Control Events unlike in VB.NET?
Hey Guys,
I was wondering if it is possible to display all Events for each control just like in this screenshot for VB.NET IDE:
http://img164.imageshack.us/img164/9...harphe1.th.jpg
It is is real turn off for using C# because I have to manually add handlers in C#.
Thanks,
McoreD
Re: [2.0] Lack of autogenerating Control Events unlike in VB.NET?
After reading some differences between C# and VB.NET I came across this:
Event Handling
Another semantic difference is the event handling techniques in the two languages. In Visual Basic .Net it is possible to declare that a method can handle an event whereas, in C#, each event handler has to be added as a System.EventHandler to the actual event collection of the class instance.
Does this mean I am out of hope?
Re: [2.0] Lack of autogenerating Control Events unlike in VB.NET?
Actually, VB 2005 has taken a leaf out of C#'s book. In the current and previous versions of C# you generate or select event handlers from the Properties window. Click the Events button at the top and it will display the member events instead of the member properties. Double-click an event to generate an empty method or select an existing method from the drop-down list, which filters out all methods with incompatible signatures. VB 2005 provides this same functionality, although it's maintained the old way too.
Re: [2.0] Lack of autogenerating Control Events unlike in VB.NET?
Oh my God the Events button. That indeed does the job. Thanks jmcilhinney! I have absolutely nothing against C# now.
although it's maintained the old way too -- do you mean those Drop Down menu way in VB.NET's IDE (which is still lacking in C#) is the old way?
Re: [RESOLVED] [2.0] Lack of autogenerating Control Events unlike in VB.NET?
Yes I do. That's not to say that those drop-down lists are not useful or shouldn't be used, but they are more limited in what they can do than the Properties window. For instance, you cannot create a single method to handle multiple events that way. In VB you can create a handler for one event and then manually add another event to the Handles clause. C# has no Handles clause so there's one good reason why that mechanism is no good for C#. In VB.NET you should use whichever is most convenient at the time. I find it's about 50/50.
Re: [RESOLVED] [2.0] Lack of autogenerating Control Events unlike in VB.NET?
Understood well jmcilhinney. As usual well explained. Thank you very much.