button1.Location = new Point(20, 200);
如果可用,望采纳~~
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace CShapWindows_Demo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//动态生成的按钮
private Button btn_dynamic; //修改动态按钮的坐标
private Button btn_modPoint; private void Form1_Load(object sender, EventArgs e)
{
btn_dynamic = new Button();
btn_dynamic.Text = "动态添加的按钮";
btn_dynamic.Location = new Point(1, 1); btn_modPoint = new Button();
btn_modPoint.Text = "修改动态按钮的坐标";
//让修改按钮在窗体的中心
btn_modPoint.Location = new Point(this.Width / 2 - btn_modPoint.Width / 2, this.Height / 2 - btn_modPoint.Height / 2);
btn_modPoint.Click += new EventHandler(btn_modPoint_Click); this.Controls.Add(btn_dynamic);
this.Controls.Add(btn_modPoint); } void btn_modPoint_Click(object sender, EventArgs e)
{
//修改动态按钮的坐标
btn_dynamic.Location = new Point(20, 20);
}
}
}
button.location=new location(x,y);这样试试
X 表示以十六进制形式输出
02 表示不足两位,前面补0输出;出过两位,不影响
举例:
printf("%02X", 0x123); //打印出:123
printf("%02X", 0x1); //打印出:01
左边顶边数据写到代码里不行吗