How to remove event handler codes

前端 未结 1 1679
猫巷女王i
猫巷女王i 2020-12-07 06:23

When I try to delete those empty handlers the form gets broken. How can I remove those annoying codes from my program without affecting form?

相关标签:
1条回答
  • 2020-12-07 06:51

    When you delete the btnOrder_Click you should also delete the following line in yourForm.Designer.cs:

    this.btnOrder.Click += new System.EventHandler(this.btnOrder_Click);
    

    To find this line after you removed the btnOrder_Click rebuild your project and then in the Error List window double click on error which says:

    'WindowsFormsApplication1.Form1' does not contain a definition for 'btnOrder_Click' and no extension method 'btnOrder_Click' accepting a first argument of type 'WindowsFormsApplication1.Form1' could be found (are you missing a using directive or an assembly reference?)

    By double clicking on this error you will redirect to that line and after deleting that line your form returns back.

    0 讨论(0)
提交回复
热议问题