动态生成按钮以及生产按钮事件

zhouzangood 2009-08-22 10:04:09
public void mybottom()//动态生成按钮
{
int j = 0;
int bottom_name = 1;
for (int i = 0; i < 6; i++)
{
Button myButton = new Button();
myButton.Name = bottom_name.ToString();
myButton.Size = new Size(70, 25);
myButton.Text = "查看";
myButton.Left = 1017 ;
myButton.Top = 33 + j ;
this.pn_picture.Controls.Add(myButton);
j += 30;
myButton.Click += new System.EventHandler(this.btn_Click);
bottom_name++;
}
}

private void btn_Click(object sender, System.EventArgs e)//动态生成按钮的单击事件
{
if (sender.GetType() == typeof(Button))
{
Order_Look frm = new Order_Look();
frm.ShowDialog();
}
else
{
TextBox control = (TextBox)sender;
MessageBox.Show(control.Text + "被按动了!");
}
}
...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
deyter 2009-08-22
  • 打赏
  • 举报
回复
...
然后呢?
youdandan 2009-08-22
  • 打赏
  • 举报
回复
沙发
a296694166 2009-08-22
  • 打赏
  • 举报
回复
???

110,525

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧