Very Basic C# From Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brent

    Very Basic C# From Question

    Hi everyone. I am moving from VB.Net to C#. C# is pretty easy but i do have
    one thing i don't like that im probably doing it the hard way and want to
    see if there is an easy way to do it. When you want to code an event for a
    control on a form in VB.Net you just select the control from the left
    comobox on top of the code window. You then select the event from the right
    combobox. Apparently C# doesn't have this. Say you want to code off the
    LostFocus event on button 1. The way i currently do it is to write the
    following code manually:

    this.button1.Lo stFocus += System.EventHan dl..........

    This is kind of a pain. You have to manually code the event handler function
    and you also have to look at exactly what type of eventargs to pass in the
    function? Is there an easier way to do this or is this the only way?



    thanks

    Brrent


  • Carlos J. Quintero [.NET MVP]

    #2
    Re: Very Basic C# From Question

    The Properties window of C# controls have an Events button that VB does not
    have.

    --

    Best regards,

    Carlos J. Quintero

    MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
    You can code, design and document much faster.
    Free resources for add-in developers:
    MZ-Tools has a single goal: To make your everyday programming life easier. As an add-in to several Integrated Development Environment (IDEs) from Microsoft, MZ-Tools adds new menus and toolbars to them that provide many new productivity features.


    "Brent" <brentwa@spam.h otmail.com> escribió en el mensaje
    news:ez7ojswVFH A.4076@TK2MSFTN GP14.phx.gbl...[color=blue]
    > Hi everyone. I am moving from VB.Net to C#. C# is pretty easy but i do
    > have one thing i don't like that im probably doing it the hard way and
    > want to see if there is an easy way to do it. When you want to code an
    > event for a control on a form in VB.Net you just select the control from
    > the left comobox on top of the code window. You then select the event from
    > the right combobox. Apparently C# doesn't have this. Say you want to code
    > off the LostFocus event on button 1. The way i currently do it is to write
    > the following code manually:
    >
    > this.button1.Lo stFocus += System.EventHan dl..........
    >
    > This is kind of a pain. You have to manually code the event handler
    > function and you also have to look at exactly what type of eventargs to
    > pass in the function? Is there an easier way to do this or is this the
    > only way?
    >
    >
    >
    > thanks
    >
    > Brrent
    >
    >[/color]


    Comment

    • Steve Long

      #3
      Re: Very Basic C# From Question

      Well, the other way to do it is to select the control or form that you want
      to add an event handler for and click the events button on the properties
      window, then double click the event handler you want to add. Simple right?

      HTH
      Steve

      "Brent" <brentwa@spam.h otmail.com> wrote in message
      news:ez7ojswVFH A.4076@TK2MSFTN GP14.phx.gbl...[color=blue]
      > Hi everyone. I am moving from VB.Net to C#. C# is pretty easy but i do[/color]
      have[color=blue]
      > one thing i don't like that im probably doing it the hard way and want to
      > see if there is an easy way to do it. When you want to code an event for a
      > control on a form in VB.Net you just select the control from the left
      > comobox on top of the code window. You then select the event from the[/color]
      right[color=blue]
      > combobox. Apparently C# doesn't have this. Say you want to code off the
      > LostFocus event on button 1. The way i currently do it is to write the
      > following code manually:
      >
      > this.button1.Lo stFocus += System.EventHan dl..........
      >
      > This is kind of a pain. You have to manually code the event handler[/color]
      function[color=blue]
      > and you also have to look at exactly what type of eventargs to pass in the
      > function? Is there an easier way to do this or is this the only way?
      >
      >
      >
      > thanks
      >
      > Brrent
      >
      >[/color]


      Comment

      • Brent

        #4
        Re: Very Basic C# From Question

        Yep sorry i didn't know it was there :). Thanks for the help. I appreciate
        it.
        "Steve Long" <Steve_Noneya@N oSpam.com> wrote in message
        news:ewlBP2wVFH A.1148@tk2msftn gp13.phx.gbl...[color=blue]
        > Well, the other way to do it is to select the control or form that you
        > want
        > to add an event handler for and click the events button on the properties
        > window, then double click the event handler you want to add. Simple right?
        >
        > HTH
        > Steve
        >
        > "Brent" <brentwa@spam.h otmail.com> wrote in message
        > news:ez7ojswVFH A.4076@TK2MSFTN GP14.phx.gbl...[color=green]
        >> Hi everyone. I am moving from VB.Net to C#. C# is pretty easy but i do[/color]
        > have[color=green]
        >> one thing i don't like that im probably doing it the hard way and want to
        >> see if there is an easy way to do it. When you want to code an event for
        >> a
        >> control on a form in VB.Net you just select the control from the left
        >> comobox on top of the code window. You then select the event from the[/color]
        > right[color=green]
        >> combobox. Apparently C# doesn't have this. Say you want to code off the
        >> LostFocus event on button 1. The way i currently do it is to write the
        >> following code manually:
        >>
        >> this.button1.Lo stFocus += System.EventHan dl..........
        >>
        >> This is kind of a pain. You have to manually code the event handler[/color]
        > function[color=green]
        >> and you also have to look at exactly what type of eventargs to pass in
        >> the
        >> function? Is there an easier way to do this or is this the only way?
        >>
        >>
        >>
        >> thanks
        >>
        >> Brrent
        >>
        >>[/color]
        >
        >[/color]


        Comment

        Working...