Results 1 to 4 of 4

Thread: "handles" in C#

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    "handles" in C#

    In VB.NET I can use the "Handle" word to cause separate controls to react to the same event. How do I do this in C#

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: "handles" in C#

    In C#, you subscribe to an event like so:

    PHP Code:
    //example, the form's click handler
    this.Click += new System.EventHandler(this.Form1_Click); 
    And then use Form1_Click{}

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: "handles" in C#

    The easy way:

    To create an event handler in C# or C++

    1. Click the form or control that you want to create an event handler for.
    2. In the Properties window, click the Events button ().
    3. In the list of available events, click the event that you want to create an event handler for.
    4. In the box to the right of the event name, type the name of the handler and press ENTER.

    Tip Name the event handler according to the functionality of the event; for example, for the Click event, you can type StartProcess as the event handler.

    The Code Editor appears, showing the code for the form, and an event handler method is generated in your code similar to the following:

    PHP Code:
    // C#
    private void StartProcess(object senderSystem.EventArgs e
    {
       
    // Add event handler code here.
    }
    // C++
    private:
      
    System::Void StartProcess(System::Object *  sender,
        
    System::EventArgs *  e)
      {
        
    // Add event handler code here.
      

    5. Add the appropriate code to the event handler.
    http://msdn.microsoft.com/library/de...nthandlers.asp

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Resolved Re: "handles" in C#

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width