试图将两个组件交换到正确的位置

Trying to swap to components to the right position

我正在努力在 C# 中交换两个组件,一个按钮(Windows 表单)比另一个大,我认为这是问题的原因。

这是开始时的样子:

最终结果应该是这样的:

然而,使用我的代码,结果最终会执行以下操作:

我的代码:

 tempC.Location = btnBlockSix.Location; //tempC is a dynamic button (temporarily used to save values), btnBlockSix is also a button (the big one).
 btnBlockSix.Location = send.Location; //send is a button (the small one) (the empty button)
 send.Location = tempC.Location;

我错了还是你们其中一个按钮比另一个大?因为那时你必须做这样的事情:

     tempC.Location = btnBlockSix.Location; //tempC is a button.

     btnBlockSix.Location = send.Location; //send is a button (the empty button)[enter image description here][1]

     send.Location = tempC.Location.Y - (btnBlockSix.height - send.Location.height);

或者类似这样的东西。 您的 post 对按钮的描述很不清楚