错误 1 当前上下文中不存在名称“btn_Click” d:\用户目录\我的文档\visual studio 2010\Projects\ch06\ch06\M
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ch06.Examples;
namespace ch06
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
foreach(var v in this.Controls)
{
Button btn=v as Button;
if(btn!=null)
{
btn.Click +=btn_Click;
}
}
}
void button1_Click(object sender, EventArgs e)
{
string s=(sender as Button).Text;
switch(s)
{
case"例1":
EnvironmentExample fm1=new EnvironmentExample();
fm1.ShowDialog();
break;
}
}
}
}