日期:2014-05-20 浏览次数:20850 次
private void Form1_Load(object sender, EventArgs e) { Button btn; for (int i = 0; i < 10; i++) { btn = new Button(); btn.Location = new System.Drawing.Point(34, 12 + i * 30);//10按钮垂直排列 btn.Name = "button" + i.ToString(); btn.Size = new System.Drawing.Size(75, 23); btn.TabIndex = 0; btn.Text = "button" + i.ToString(); btn.UseVisualStyleBackColor = true; this.Controls.Add(btn); btn.Click += new EventHandler(btn_Click); } } void btn_Click(object sender, EventArgs e) { Button button = (Button)sender; MessageBox.Show("你现在点击的是按钮" + button.Text); }
------解决方案--------------------
如果楼主说的是asp.net,我曾经发过一个小例子,希望对你有用:
http://topic.csdn.net/u/20100704/09/64bf7b0d-8ee8-4b84-b064-3c1629dc1d9c.html
------解决方案--------------------