load事件是窗体的加载事件,当然不能在其中关闭窗体了。
不过你可在unload事件中关闭窗体。

解决方案 »

  1.   

    这是个子窗体;
    我在工作,所以就加了个子窗体;
    我这里可以关的呀;
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;namespace WindowsApplication4
    {
    /// <summary>
    /// Form2 的摘要说明。
    /// </summary>
    public class Form2 : System.Windows.Forms.Form
    {
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.Container components = null;
    private bool CheckClosed;public Form2()
    {
    //
    // Windows 窗体设计器支持所必需的
    //
    InitializeComponent(); //
    // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
    //
    }/// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    protected override void Dispose( bool disposing )
    {
    if( disposing )
    {
    if(components != null)
    {
    components.Dispose();
    }
    }
    base.Dispose( disposing );
    }#region Windows Form Designer generated code
    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
    // 
    // Form2
    // 
    this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
    this.ClientSize = new System.Drawing.Size(480, 273);
    this.Name = "Form2";
    this.Text = "Form2";
    this.Load += new System.EventHandler(this.Form2_Load);
    this.Layout += new System.Windows.Forms.LayoutEventHandler(this.Form2_Layout);}
    #endregionprivate void Form2_Load(object sender, System.EventArgs e)
    {
    //你在这里加入验证;决定CheckClosed
    this.CheckClosed=true;
    }private void Form2_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
    {
    if(this.CheckClosed)
    this.Close();
    }
    }
    }
      

  2.   

    在Load事件中用这个试一试:Application.Exit();private void Form1_Load(object sender, System.EventArgs e)
    {
    int i = 0;
    if (i == 0) Application.Exit();
    }
      

  3.   

    在Form_Resize事件中进行UNLOAD。
    不过这样,可能有界面一闪的情况
      

  4.   

    对于
    Form里的私有数据,可以给出访问的属性,在调用方直接读取或设置其属性。
      

  5.   

    回poetc,我也按你这样试了一下,真不行,出现异常“执行 CreateHandle() 时无法调用 Close()”
      

  6.   

    以下代码未经验证
    public void ShowMe()
    {
       if(条件)
          this.Close();
        else
          this.Show();
    }用form1.ShowMe();显示窗体
      

  7.   

    Heray(Heray) ( ),你把你的代码贴出来;我这里没有任何问题呀.