怎么清除Visual Studio .NET里自动生成的那些事件和定义啊?都得手工删吗?
1、比如有一个Button对应一个click事件,Delphi可以自动清除空的click,Visual Studio .NET怎么让它自动清除?
2、如果删了Button怎么自动清除它相关的定义啊。

解决方案 »

  1.   

    不要去双击button就不会生成button事件,删除的时候最好在设计视图删除button,这样就可以一起把事件删除掉
      

  2.   

    楼上的,你错了,设计视图也不会自动删除事件的,至少目前我遇到的click什么的事件是不会被删除的。
    我一般是先手动删除事件,然后删除button控件,然后run一下,这个时候会报错说“未定义的操作什么的”,查看错误找到委托语句,删除之。
    这是2003里面,还没尝试过2005。不清楚有没有变化。
      

  3.   

    private void InitializeComponent()
    {    
    this.ibtnPerLogin.Click += new System.Web.UI.ImageClickEventHandler(this.ibtnPerLogin_Click);
    this.PIbtn.Click += new System.Web.UI.ImageClickEventHandler(this.PIbtn_Click);
    this.PN.Click += new System.Web.UI.ImageClickEventHandler(this.PN_Click);
    this.EIbtn.Click += new System.Web.UI.ImageClickEventHandler(this.EIbtn_Click);
    this.EN.Click += new System.Web.UI.ImageClickEventHandler(this.EN_Click);
    this.PEbtn.Click += new System.Web.UI.ImageClickEventHandler(this.PEbtn_Click);
    this.PEbtn1.Click += new System.Web.UI.ImageClickEventHandler(this.PEbtn1_Click);
    this.DataList2.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.DataList2_ItemDataBound);
    this.DataList1.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.DataList1_ItemDataBound);
    this.Load += new System.EventHandler(this.Page_Load); }
    绑定的事件都在方法InitializeComponent()里,不用可以直接删除绑定代码和方法
      

  4.   

    举例:
    比如说要清除btnButton的Click事件:在InitializeComponent()函数里(在Window Form Designer Code Region里,点开前面的+展开代码就可以看见,或者在Form的构造函数里右键这个函数的定义,快捷键F12)//btnButton
    this.btnButton.Location = new System.Drawing.Point(104, 168);
    this.btnButton.Name = "btnButton";
    this.btnButton.Size = new System.Drawing.Size(80, 32);
    this.btnButton.TabIndex = 0;
    this.btnButton.Text = "button1";
    //this.btnButton.Click += new System.EventHandler(this.button1_Click);
    屏蔽或删掉这行代码然后到事件定义的函数去
    //private void btnButton_Click(object sender, System.EventArgs e)
    //{
    // 。。
    //}
    屏蔽或删掉这块代码就OK啦
      

  5.   

    看来是必须手动删了?还是Delphi自动清除空事件的功能好啊。