在C#中怎样动态添加按钮?

swordson 2010-01-03 01:09:46
1)C#怎样动态添加按钮 就是用代码在WINDOWS窗体上生成一些按钮 就可以了。 谢谢哈!!!
...全文
202 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
collinzhaoqi 2010-01-08
  • 打赏
  • 举报
回复
学习
fzsyshow 2010-01-08
  • 打赏
  • 举报
回复
楼上已经写得挺清楚的了
蓝色韵脚 2010-01-03
  • 打赏
  • 举报
回复
Button button=new Button();
/** 这是添加属性,可以不用要,但可以看看
button.BackColor=System.Drawing.SystemColors.Desktop;
button.FlatStyle=System.Windows.Forms.FlatStyle.Standard;
button.ForeColor=System.Drawing.SystemColors.Control;
button.Text="确定";
button.Visible=true;
button.Size=new System.Drawing.Size(56,32);
**/
button.Click+=new System.EventHandler(this.button_Click); //这是添加事件
dabendano 2010-01-03
  • 打赏
  • 举报
回复
Button b = new Button();            
//按钮显示字体
b.Text = "按钮名称";
//按钮位置
b.Location = new Point(10,20);
this.Controls.Add(b);

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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