窗体上有几十个按钮,
 
 怎么写代码让点击任何一个按钮都 弹出同一个窗体? 一个一个写太麻烦了,我想这肯定有简单的办法。有智者给指下明路?

解决方案 »

  1.   

            public Form1()
            {
                InitializeComponent();            foreach (Control ctl in this.Controls)
                {
                    Button btn = ctl as Button;
                    if (btn != null)
                    {
                        btn.Click += new EventHandler(btn_Click);
                    }
                }
            }        private void btn_Click(object sender, EventArgs e)
            {
                Form2 frm = new Form2();
                frm.Show();
            }