Export (0) Print
Expand All

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.

Note Note

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 Customizing Development 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

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

© 2014 Microsoft