VC# 有分数啊 我想获取button的左上角的坐标

来源:百度知道 编辑:UC知道 时间:2024/06/30 11:42:36
private void button1_Click(object sender, EventArgs e)
{
double A = btn2.Location.X;
double B = btn2.Location.Y;
A = 400.0;
B = 400.0;
}

我想单击button1后 btn2的位置发生变化 变到400,400这个位置 这么写怎么不行啊? 还有 C#里随机函数的格式是怎么样的啊 ?
我知道了~~!!!btn2.Location.Y 是只读的 不能改写
要改的话这样才行
btn2.Location = new System.Drawing.Point(4, 21);

private void button1_Click(object sender, EventArgs e)
{
double A = 400;
double B = 400;
btn2.Location.X=A;
btn2.Location.Y=B;

}

你得先给A、B赋值,然后再让位置属性的值等于A和B