在SDSJ.cs中有下面一个方法 private void SDSJ_Shown(object sender, EventArgs e)
        {
            if (!InitXls(_xlsName))
                _failedInit = true;
            if (_failedInit)
                this.Close();
        }
我在SDSJ.Designer.cs里面添加了这个触发事件可就是没反应啊// 
            // SDSJ
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(736, 493);
            this.Controls.Add(this.axFramerControl1);
            this.Name = "SDSJ";
            this.Text = "SDSJ";
            this.Load += new System.EventHandler(this.SDSJ_Load);
            this.Shown += new System.EventHandler(this.SDSJ_Shown);
            this.Click += new System.EventHandler(this.SDSJ_Load);
            this.Click += new System.EventHandler(this.SDSJ_Shown);
            ((System.ComponentModel.ISupportInitialize)(this.axFramerControl1)).EndInit();
            this.ResumeLayout(false);

解决方案 »

  1.   


    调试,设个断点试一下,看有没有触发.
    触发的话
    不知道你的业务逻辑,可能下面也有关系
    this.Click += new System.EventHandler(this.SDSJ_Load);
    this.Click += new System.EventHandler(this.SDSJ_Shown);
    这个时间触发这两个事件处理的顺序是随机的.
      

  2.   


    private void SDSJ_Shown(object sender, EventArgs e)
            {
             //   if (!InitXls(_xlsName))
              //      _failedInit = true;
            //    if (_failedInit)
             //       this.Close();
    MessageBox.Show("hello");
            }估计是你这里面的有问题,要不信你试一下上面的
      

  3.   

    我不是很懂 
    说下思路
    在新弹出的那个窗口的load事件里面添加你要触发的东西 应该可以
      

  4.   

    这个是可以,但是用那个控件时会弹出调用目标错误的信息,所以必须再自定义个触发函数.加个button触发也可以,但是不想那样,就想让程序自己添加个方法,然后执行完load后触发这个事件