using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("已经单击了窗体!");
        }
    }
}

解决方案 »

  1.   


    //需要为当前对象添加单击事件才可以响应事件方法
    this.Click += new System.EventHandler(this.Form1_Click);
      

  2.   

    看一下解决方案管理器里面的 Form1.Designer.cs 文件 是否包含如下代码:
       this.Click += new System.EventHandler(this.Form1_Click);
    这个是 事件和委托挂钩。
      

  3.   

    好的,总算明白了.因为你点别的位置的时候 需要响应其他位置的事件比如你form1中有其他的控件,则需要在其他控件的Click事件中也增加这个事件处理
    //为button1添加单击
    this.button1.Click += new System.EventHandler(this.Form1_Click);
      

  4.   

    为什么得自己亲自在Form1.Designer.cs里面添加
    this.Click += new System.EventHandler(this.Form1_Click);
    因为我之前都只是在Form1.cs编写代码的呀???