Writing event handlers in C#


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: Writing event handlers in C#

  1. #1
    Frank Oquendo Guest

    Writing event handlers in C#

    Coming from VB/VB.NET, I appreciate C#'s terseness when it comes to event
    handler signatures but how do you look them up?

    In the code window, the only object shown in the object list is my form. I
    find myself having to refer to the help in order to determine the correct
    signature. Once I've got that done, I then either have to modify the
    wizard-generated code to attach the handler or use the Properties window to
    associate my handler with an event.

    Is there an easier way?

    --
    Good judgment comes from experience.
    Experience comes from bad judgment.

    http://www.acadx.com





  2. #2
    Jonathan Allen Guest

    Re: Writing event handlers in C#

    > Coming from VB/VB.NET, I appreciate C#'s terseness when it comes to event
    > handler signatures


    Huh? VB.Net has the same event signatures as C#.

    Anyways, you should be able to use the property window to generate the event
    code. If I remember correctly, you just have to double-click on the event
    name.

    --
    Jonathan Allen



    "Frank Oquendo" <franko@acadx.com> wrote in message
    news:3c0c0d22$1@147.208.176.211...
    > Coming from VB/VB.NET, I appreciate C#'s terseness when it comes to event
    > handler signatures but how do you look them up?
    >
    > In the code window, the only object shown in the object list is my form. I
    > find myself having to refer to the help in order to determine the correct
    > signature. Once I've got that done, I then either have to modify the
    > wizard-generated code to attach the handler or use the Properties window

    to
    > associate my handler with an event.
    >
    > Is there an easier way?
    >
    > --
    > Good judgment comes from experience.
    > Experience comes from bad judgment.
    >
    > http://www.acadx.com
    >
    >
    >
    >



  3. #3
    Frank Oquendo Guest

    Re: Writing event handlers in C#

    C#:
    private void DragDropHandler(object sender,
    System.Windows.Forms.DragEventArgs e)

    VB.NET:
    Private Sub DragDropHandler(ByVal sender As Object, ByVal e As
    System.Windows.Forms.DragEventArgs)

    The extra specifiers add up. Not to mention the rest of the language is also
    quite terse. I love VB but all that verbosity is starting to get to me. It's
    amazing how similar the syntax is. Casting is a whole lot easier, too. I may
    have to start doing some serious digging into C#.

    In any event, thanks for the double-click thing. That certainly is handy.

    --
    Good judgment comes from experience.
    Experience comes from bad judgment.

    http://www.acadx.com


    "Jonathan Allen" <greywolf@cts.com> wrote in message
    news:3c0c1705@147.208.176.211...
    >
    > Huh? VB.Net has the same event signatures as C#.
    >
    > Anyways, you should be able to use the property window to generate the

    event
    > code. If I remember correctly, you just have to double-click on the event
    > name.
    >
    > --
    > Jonathan Allen




  4. #4
    Jonathan Allen Guest

    Re: Writing event handlers in C#

    > The extra specifiers add up. Not to mention the rest of the language is
    also
    > quite terse.


    That depends on how you measure the length of the line. If you count tokens
    instead of characters, VB is often shorter than C#. Especially when you can
    take advantage of special modifiers like Handles, which can eliminate many
    lines of code.

    > Casting is a whole lot easier, too.


    I do not like the casting in either language, but that is another battle.

    --
    Jonathan Allen



    "Frank Oquendo" <franko@acadx.com> wrote in message
    news:3c0c1c29@147.208.176.211...
    > C#:
    > private void DragDropHandler(object sender,
    > System.Windows.Forms.DragEventArgs e)
    >
    > VB.NET:
    > Private Sub DragDropHandler(ByVal sender As Object, ByVal e As
    > System.Windows.Forms.DragEventArgs)
    >
    > The extra specifiers add up. Not to mention the rest of the language is

    also
    > quite terse. I love VB but all that verbosity is starting to get to me.

    It's
    > amazing how similar the syntax is. Casting is a whole lot easier, too. I

    may
    > have to start doing some serious digging into C#.
    >
    > In any event, thanks for the double-click thing. That certainly is handy.
    >
    > --
    > Good judgment comes from experience.
    > Experience comes from bad judgment.
    >
    > http://www.acadx.com
    >
    >
    > "Jonathan Allen" <greywolf@cts.com> wrote in message
    > news:3c0c1705@147.208.176.211...
    > >
    > > Huh? VB.Net has the same event signatures as C#.
    > >
    > > Anyways, you should be able to use the property window to generate the

    > event
    > > code. If I remember correctly, you just have to double-click on the

    event
    > > name.
    > >
    > > --
    > > Jonathan Allen

    >
    >



  5. #5
    Zane Thomas Guest

    Re: Writing event handlers in C#

    On Mon, 3 Dec 2001 19:12:09 -0800, "Jonathan Allen" <greywolf@cts.com>
    wrote:

    >That depends on how you measure the length of the line. If you count tokens
    >instead of characters, VB is often shorter than C#.


    That's certainly not the case in the post you replied to. What's up with
    you anyway? If you don't like c# that's fine, don't use it, but then I
    don't like vb.net so I guess that makes us even.


    --
    It's never too late to have
    a happy childhood.

  6. #6
    Kunle Odutola Guest

    Re: Writing event handlers in C#


    "Jonathan Allen" <greywolf@cts.com> wrote in message
    news:3c0c3106@147.208.176.211...
    > > The extra specifiers add up. Not to mention the rest of the language is

    > also
    > > quite terse.

    >
    > That depends on how you measure the length of the line.


    Hey?

    > If you count tokens
    > instead of characters, VB is often shorter than C#.


    If you count semicolons only, you'll find that VB lines are always shorter
    than C# lines. But what does that prove?

    Kunle



  7. #7
    djdjdj dkskdsk Guest

    Re: Writing event handlers in C#

    Jonathan,

    > Anyways, you should be able to use the property window to generate the

    event
    > code. If I remember correctly, you just have to double-click on the event
    > name.
    >


    Is there an IDE shortcut for getting the signature of methods you want to
    override?

    Michael



  8. #8
    Jonathan Allen Guest

    Re: Writing event handlers in C#

    > If you count semicolons only, you'll find that VB lines are always shorter
    > than C# lines. But what does that prove?


    It proves that C# uses to many semi-colons. Seriously though, I count line
    length by tokens instead of characters because that is how I think.

    When most people see "equals", they see a single word. They do not think of
    it as a series of letters to be considered individually. The same goes for C
    programmers, who see "==" as the equality operator instead of two equal
    signs in a row. The same goes for VB keywords. When I see "Then" or "Loop",
    I see it the same way you see "{" or "}".

    --
    Jonathan Allen



    "Kunle Odutola okocha.freeserve.co.uk>" <kunle.odutola@<REMOVETHIS> wrote in
    message news:3c0d8b7e@147.208.176.211...
    >
    > "Jonathan Allen" <greywolf@cts.com> wrote in message
    > news:3c0c3106@147.208.176.211...
    > > > The extra specifiers add up. Not to mention the rest of the language

    is
    > > also
    > > > quite terse.

    > >
    > > That depends on how you measure the length of the line.

    >
    > Hey?
    >
    > > If you count tokens
    > > instead of characters, VB is often shorter than C#.

    >
    > If you count semicolons only, you'll find that VB lines are always shorter
    > than C# lines. But what does that prove?
    >
    > Kunle
    >
    >



  9. #9
    Michael Welch Guest

    Re: Writing event handlers in C#

    Ooops, sorry about that "djdjdj dkskdsk" nonsense.

    Michael

    "djdjdj dkskdsk" <not@valid.com> wrote in message
    news:3c0eb81c@147.208.176.211...
    > Jonathan,
    >
    > > Anyways, you should be able to use the property window to generate the

    > event
    > > code. If I remember correctly, you just have to double-click on the

    event
    > > name.
    > >

    >
    > Is there an IDE shortcut for getting the signature of methods you want to
    > override?
    >
    > Michael
    >
    >




  10. #10
    Jonathan Allen Guest

    Re: Writing event handlers in C#

    > Is there an IDE shortcut for getting the signature of methods you want to
    > override?


    I wish I could tell you, but I just lost both of my .Net machines. I cannot
    play with it again until it is released (so I can put it on my production
    machine) or my boss is done with my spares.

    --
    Jonathan Allen



    "djdjdj dkskdsk" <not@valid.com> wrote in message
    news:3c0eb81c@147.208.176.211...
    > Jonathan,
    >
    > > Anyways, you should be able to use the property window to generate the

    > event
    > > code. If I remember correctly, you just have to double-click on the

    event
    > > name.
    > >

    >
    > Is there an IDE shortcut for getting the signature of methods you want to
    > override?
    >
    > Michael
    >
    >



  11. #11
    Zane Thomas Guest

    Re: Writing event handlers in C#

    On Wed, 5 Dec 2001 18:24:09 -0800, "Jonathan Allen" <greywolf@cts.com>
    wrote:

    >It proves that C# uses to many semi-colons.


    Whatever, so use vb.net. I really don't think anyone cares.



    --
    When freedom is outlawed
    only outlaws will be free.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center