怎样添加个button?

ycnet 2004-12-17 03:30:08
using System;
using System.Windows.Forms;
using System.Drawing;

class HelloWindows
{
public static void Main()
{
Form myForm=new Form();

Application.Run(myForm);

}

}


在不是可视化下编写
如果写?
谢谢
...全文
116 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sunnydde 2004-12-17
  • 打赏
  • 举报
回复
Button mybtn=new Button();
mybtn.Size=new Size(xx,xx)//按钮大小
mybtn.Location =new Point(xx,xx)//按钮的位置
mybtn.Parent=this.xxxx //要包含按钮的控件
hanbinghai 2004-12-17
  • 打赏
  • 举报
回复
using System;
using System.Windows.Forms;
using System.Drawing;

class HelloWindows
{

public static void Main()
{
Form myForm=new Form();
Button btn = new Button();
//btn.Location = new System.Drawing.Point(1, 1);
myForm.Controls.Add(btn);
Application.Run(myForm);
}

}
hatita 2004-12-17
  • 打赏
  • 举报
回复
"在不是可视化下编写"什么意思?

private void Form1_Load(object sender, System.EventArgs e)
{
Button button = new Button();
this.Controls.Add(button);
}

110,534

社区成员

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

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

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