The requested page is not available for the requested platform. You are viewing the content for Default platform.

Remove Empty Handler

Removes an empty event handler along with the event handler assignment.

Availability

Available from the context menu or via shortcuts:

  • when the edit cursor or caret is on an empty method that handles an event.
Note

This refactoring is only available in Windows Forms applications.

Example

class TestClass
{
    public TestClass()
    {
        TestButton = new Button();
        TestButton.Click += TestButton_Click;   
    }
    public Button TestButton;
    private void TestButton_Click(Object Sender, EventArgs e)
    {

    }
}
Class TestClass
    Public Sub New()
        TestButton = New Button()
    End Sub
    Friend WithEvents TestButton As Button
    Private Sub TestButton_Click(ByVal Sender As Object, _
        ByVal e As EventArgs) Handles TestButton.Click

    End Sub
End Class

Result:

class TestClass
{
    public TestClass()
    {
        TestButton = new Button();
    }
    public Button TestButton;
}
Class TestClass
    Public Sub New()
        TestButton = New Button()
    End Sub
    Friend WithEvents TestButton As Button
End Class

Screenshot

rsRemoveEmptyHandler