如何删除事件处理程序代码 [英] How to remove event handler codes

查看:110
本文介绍了如何删除事件处理程序代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试删除那些空的处理程序时,表格会损坏。如何在不影响表单的情况下从程序中删除那些烦人的代码?

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?

推荐答案

删除 btnOrder_Click 时,还应在 yourForm中删除以下行。 Designer.cs

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

在删除 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'不包含'btnOrder_Click'的定义,并且找不到扩展方法'btnOrder_Click'接受类型为'WindowsFormsApplication1.Form1'的第一个参数(您是否缺少using指令或程序集引用?)

'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.

这篇关于如何删除事件处理程序代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆