C#动态创建button的方法
来源:本站原创|时间:2022-11-25|栏目:C#教程|
本文实例讲述了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#程序设计有所帮助。
您可能感兴趣的文章
- 01-10winform实现创建最前端窗体的方法
- 01-10Winform消除button按下出现的虚线简单实现方法
- 01-10深入浅出23种设计模式
- 01-10winform创建不规则窗体的方法
- 01-10C#动态创建Access数据库及密码的方法
- 01-10C#实现在启动目录创建快捷方式的方法
- 01-10C#获取动态生成的CheckBox值
- 01-10C#中DataGridView动态添加行及添加列的方法
- 01-10C#创建不规则窗体的4种方式详解
- 01-10轻松学习C#的ArrayList类