动态控件--如何让他们工作呢? 比如我创建了5个button,都是用程序创建的.我想写他们的click事件,怎么办呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void FormCalc_Load(object sender, EventArgs e){ Button vButton; vButton = new Button(); vButton.Text = "保存"; vButton.Tag = "save"; vButton.Parent = this; vButton.Click += new EventHandler(vButton_Click); vButton = new Button(); vButton.Top = 30; vButton.Text = "载入"; vButton.Tag = "load"; vButton.Parent = this; vButton.Click += new EventHandler(vButton_Click);}void vButton_Click(object sender, EventArgs e){ switch((string)((Button)sender).Tag) { case "save": MessageBox.Show("保存"); break; case "load": MessageBox.Show("载入"); break; }} 把事件写好了还要加载this.vButton.Click += new System.EventHandler(this.Columns_SelectedIndexChanged); 我在创建button时如下写: button mybutton = new button(); mybutton.Location = new System.Drawing.Point(12, 31); mybutton.Name = "fangan1"; mybutton.TabIndex = 0; mybutton.Size = new Size(41, 12); mybutton.Text = "方案1:"; this.Controls.Add(mybutton); mybutton.Visible = true;不正确,谢谢,指点下我. button -> Button// ~~ 不会是这个小写吧-_-!! WPF如何把资源文件的图片动态的设置成grid的背景图片? 已知圆弧的起点、终点及半径求圆弧的起始角度和终点角度? combox动态绑定 求正则表达式. 如何实现当客户端一收到信息,服务器端就马上提示发送成功(象QQ的小喇叭消息提示那样) 简单问题 安装和部署项目问题 请问如何 在一个SQLCOMMAND里面执行多条SQL语句 网页嵌入excel无法显示 100分求助!!!!!arcgis engine ,如何查询到的某条街道在屏幕中间显示? RichTextBox的问题 求时间进度条代码
{
Button vButton;
vButton = new Button();
vButton.Text = "保存";
vButton.Tag = "save";
vButton.Parent = this;
vButton.Click += new EventHandler(vButton_Click);
vButton = new Button();
vButton.Top = 30;
vButton.Text = "载入";
vButton.Tag = "load";
vButton.Parent = this;
vButton.Click += new EventHandler(vButton_Click);
}void vButton_Click(object sender, EventArgs e)
{
switch((string)((Button)sender).Tag)
{
case "save":
MessageBox.Show("保存");
break;
case "load":
MessageBox.Show("载入");
break;
}
}
this.vButton.Click += new System.EventHandler(this.Columns_SelectedIndexChanged);
mybutton.Location = new System.Drawing.Point(12, 31);
mybutton.Name = "fangan1";
mybutton.TabIndex = 0;
mybutton.Size = new Size(41, 12);
mybutton.Text = "方案1:";
this.Controls.Add(mybutton);
mybutton.Visible = true;不正确,谢谢,指点下我.
// ~~ 不会是这个小写吧-_-!!