Export (0) Print
Expand All
2 out of 7 rated this helpful - Rate this topic

How to: Create Default Event Handlers on the Windows Forms Designer 

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.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

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:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    'Add event-handler code here
    End Sub
    
    
    

    private void button1_Click(object sender, System.EventArgs e) 
    {
    // Add event-handler code here.
    }
    
    

    private:
      void button1_Click(System::Object ^ sender,
        System::EventArgs ^ e)
      {
    // Add event-handler code here.
      }
    

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

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.