在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);
{
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);
调试,设个断点试一下,看有没有触发.
触发的话
不知道你的业务逻辑,可能下面也有关系
this.Click += new System.EventHandler(this.SDSJ_Load);
this.Click += new System.EventHandler(this.SDSJ_Shown);
这个时间触发这两个事件处理的顺序是随机的.
private void SDSJ_Shown(object sender, EventArgs e)
{
// if (!InitXls(_xlsName))
// _failedInit = true;
// if (_failedInit)
// this.Close();
MessageBox.Show("hello");
}估计是你这里面的有问题,要不信你试一下上面的
说下思路
在新弹出的那个窗口的load事件里面添加你要触发的东西 应该可以