【发布时间】:2012-05-13 12:47:36
【问题描述】:
我的 winform c# 项目有问题。 在我的项目中,我有两个主要功能,一个在运行时制作按钮,另一个功能允许我在运行时移动表单上的按钮。现在,如果我在其他按钮上有按钮,我该怎么办,所以我制作了替换按钮位置的功能,但如果有人可以帮助我,该功能会出现问题,那就太好了!
public void upandunder(Button cBtn1, Button cBtn2)
{
if ((cBtn1.Location.X == cBtn2.Location.X) && (cBtn1.Location.Y == cBtn2.Location.Y))
{
int placex = cBtn1.Location.X;
int placey = cBtn1.Location.Y;
cBtn1.Location.X = cBtn2.Location.Y;
cBtn1.Location.Y = cBtn2.Location.Y;
cBtn2.Location.X = placex;
cBtn2.Location.Y = placey;
}
}
【问题讨论】:
-
它让我认为 errorError 1 无法修改 'System.Windows.Forms.Control.Location' 的返回值,因为它不是变量 C:\Users\איתן יונה\Desktop\drawsquare2\WindowsFormsApplication1 \Form1.cs 172 17 WindowsFormsApplication1
-
从将
Button x, Button y更改为Button cBtn1, Button cBtn2开始,将使您的代码可读...