日期:2014-05-18 浏览次数:21020 次
namespace test_csharp { public partial class Form1 : Form { public delegate void openForm(object o,EventArgs e); public event openForm eventOpenForm; public Form2 newForm=new Form2(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //这样写不行 this.newForm.Shown; } private void Form1_Load(object sender, EventArgs e) { //这样写也不行 //button1_Click += eventOpenForm(this.newForm, this.newForm.Shown); } } }
private void button1_Click(object sender, EventArgs e) { this.newForm.Show(); } private void Form1_Load(object sender, EventArgs e) { eventOpenForm += new openForm(button1_Click); if (eventOpenForm!=null) { eventOpenForm(sender, e); } }