Tech Off Thread

11 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

VS 2005 C# IDE Object events???

Back to Forum: Tech Off
  • User profile image
    phreaks

    Is there a drop-down of available events for a control in C#?

    I had been told (and tested) that in VB.NEt you can select a control on the form and a drop-down box populates with all available events for that control.

    Why doesn't C# have this?

  • User profile image
    Cannot​Resolve​Symbol

    You mean like this?  (in C#2005 EE, also should be the same in VS2003)

    Image Hosted by ImageShack.us

    It's on the properties sheet.  If you just want a list of events defined in a given class, they are listed in the Object Browser.

  • User profile image
    JPeless

    I assume you are in the designer.  If you have the properties pane open when you select a control, then there is an icon in the Properties pane that looks like a lightning bolt.  Click it and you can see all the events the control can fire.   Double click any of them to create a stub method to respond to the event, or select an already existing method using the drop down control next to the event name.

  • User profile image
    phreaks

    CannotResolveSymbol wrote:
    You mean like this?  (in C#2005 EE, also should be the same in VS2003)

    Image Hosted by ImageShack.us

    It's on the properties sheet.  If you just want a list of events defined in a given class, they are listed in the Object Browser.


    OMG, I am a dumbass. I don't work with visual controls / forms very often. Thank you very much.

  • User profile image
    Sampy

    The VB one is still better. I love Handles/WithEvents much more than +=/-=. The one clear VB advantage IMO.

  • User profile image
    Ion Todirel

    maybe they should change this in C#, no reason to doing

  • User profile image
    Yggdrasil

    Sampy wrote:
    The VB one is still better. I love Handles/WithEvents much more than +=/-=. The one clear VB advantage IMO.


    Yeah, you would. Smiley

    I agree that the C# syntax is broken - a classic example of how not to overload operators. I still dislike VB's AddHandler statement, though. I prefer to have a method on an object rather than a stand-alone statement that you have to know in advance. IntelliSense allows us to learn about what we can do to an unfamiliar object, but it's no help for this kind of syntax.

  • User profile image
    AdityaG

    Sampy wrote:
    The VB one is still better. I love Handles/WithEvents much more than +=/-=. The one clear VB advantage IMO.


    I actually like how C# does it. You add a handler to an event. Instead of verbose crap like addHandler or object.AddHandler() you just do += and then -=.

  • User profile image
    pacelvi

    AdityaG wrote:
    Sampy wrote: The VB one is still better. I love Handles/WithEvents much more than +=/-=. The one clear VB advantage IMO.


    I actually like how C# does it. You add a handler to an event. Instead of verbose crap like addHandler or object.AddHandler() you just do += and then -=.


    I agree. I like C#'s way.. it's more closer to what is actually happening... and that is adding a new delegate to a chain of delegates.

  • User profile image
    Chadk

    Sampy wrote:
    The VB one is still better. I love Handles/WithEvents much more than +=/-=. The one clear VB advantage IMO.

    I agree with you, that it's a very cool feature.
    But i dont find it, after all, a valid reason to switch to vb

  • User profile image
    Yggdrasil

    pacelvi wrote:
    I agree. I like C#'s way.. it's more closer to what is actually happening... and that is adding a new delegate to a chain of delegates.


    But it breaks the metaphor. How can you subtract a NEW object from a collection?


    myObj.myEvent -= new EventHandler ();


    I like the object-oriented convention, but dislike this specific part of it.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.