当前位置: 移动技术网 > IT编程>开发语言>c# > C#动态创建button的方法

C#动态创建button的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#动态创建button的方法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.linq;
using system.text;
using system.windows.forms;
using system.reflection;
namespace app
{
  public partial class form1 : form
  {
    public form1()
    {
      initializecomponent();
      system.windows.forms.button button = new button();
      button.text = "按钮";
      button.size = new size(100, 30);
      button.location = new point(0, 0);
      button.click += delegate { buttonclick(); };
      this.controls.add(button);
    }
    void buttonclick()
    {
      messagebox.show("点击了click事件");
    }
  }
}
//注意:主要是看事件

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网