的WinForms - 视觉删除按钮单击事件 [英] Winforms - Visually remove button click event

查看:149
本文介绍了的WinForms - 视觉删除按钮单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

.NET新手警报

使用Visual C#2008 Express Edition的我不小心创造了一个按钮点击事件。然后我删除自动创建的方法的代码,这就造成了一个错误,指出该功能,现在已经在形式加载代码中引用,再也无法被发现。

Using Visual C# 2008 Express Edition I have accidentally created a click event for a button. I then deleted the automatically-created method code, which resulted in an error saying that the function, which had now been referenced in the form loading code, could no longer be found.

删除从 Form1.Designer.cs 文件的的InitializeComponent()函数以下行...

Deleting the following line from the Form1.Designer.cs file's InitializeComponent() function...

this.btnCopy.Click += new System.EventHandler(this.btnCopy_Click);



......似乎这样的伎俩,但是,它让我觉得是因为以下的非常脏在#地区的开头警告:

... seems to do the trick, however, it makes me feel very dirty because of the following warning at the beginning of the #region:

/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.



我一直没能找到一个方法来做到这一点使用表单设计器,我假设就是这个警告暗示的手段。什么是做到这一点的正确方法?

I haven't been able to find a way to do this using the form designer, which I assume is the means implied by this warning. What is the correct way to do this?

推荐答案

您确实有在designer.cs文件时要小心,但你不必觉得脏吧(当我犯同样的错误,这只是比较容易解决它designer.cs文件)。你可以做到这一点视觉上是这样的:

You do have to be careful when working in the designer.cs files but you don't have to feel dirty about it (when I make the same mistake it is just easier to fix it the designer.cs file). You can do it visually like this:


  1. 打开的窗体设计的形式。

  2. 在窗体设计器,点击感兴趣的按钮。

  3. 按F4(或右键单击该按钮,然后单击属性)。属性面板应该显示出来。

  4. 在属性面板的顶部,单击闪电。这显示为按钮的事件。

  5. 找到click事件,并清除其处理程序。

  1. Open the form in the form designer.
  2. In the form designer, click the button of interest.
  3. Press F4 (or right click the button and then click properties). The properties pane should show up.
  4. At the top of the properties pane, click the lightning bolt. This shows the events for the button.
  5. Find the click event and clear its handler.

这篇关于的WinForms - 视觉删除按钮单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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