C#button控件的坐标修改

我用代码动态生成一个button控件,想修改它的坐标用Button.Location编译出错说是 无法修改“System.Windows.Forms.Control.Location”的返回值,因为它不是变量请问怎么修改坐标?(用代码)

 

button1.Location = new Point(20, 200);

 

如果可用,望采纳~~

温馨提示:内容为网友见解,仅供参考
第1个回答  2013-04-18
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);
}
}
}
第2个回答  2013-04-18
button.location=new location(x,y);这样试试
第3个回答  2017-07-30
X 表示以十六进制形式输出
02 表示不足两位,前面补0输出;出过两位,不影响
举例:
printf("%02X", 0x123); //打印出:123
printf("%02X", 0x1); //打印出:01
第4个回答  2013-04-19
左边顶边数据写到代码里不行吗
相似回答