Export (0) Print
Expand All

Creating Default Event Handlers on the Windows Forms Designer

Visual Studio .NET 2003

Within the Windows Forms Designer, double-clicking the design surface (either the form or a control) creates an event handler for the default action for that item.

To create the event handler for a default action

  1. Double-click the item on the Windows Forms Designer for which you wish to create a handler.

    The Code Editor opens and the mouse pointer is located inside the newly created default event handler.

  2. Add the appropriate code to the event handler.

    When you finish, your code might look like this:

    ' Visual Basic
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    'Add Event Handlers Code Here
    End Sub
    
    // C#
    private void button1_Click(object sender, System.EventArgs e) 
    {
    
    }
    // C++
    private:
      System::Void button1_Click(System::Object *  sender,
        System::EventArgs *  e)
      {
      }
    

    The preceding code is the default event handler for a Button control.

See Also

Event Handling in Windows Forms | Introduction to Event Handlers in Windows Forms | Creating Event Handlers on the Windows Forms Designer | Creating Event Handlers at Run Time for Windows Forms | Creating Windows Forms | Troubleshooting Inherited Event Handlers in Visual Basic .NET

Show:
© 2014 Microsoft