C#更改对象的位置编程 [英] C# Change the location of an object programatically
本文介绍了C#更改对象的位置编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试以下code:
this.balancePanel.Location.X = this.optionsPanel.Location.X;
要改变程序运行时,但它返回一个错误,我在设计模式做出了面板的位置:
to change the location of a panel that I made in design mode while the program is running but it returns an error :
Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable
所以问题是,我该怎么办呢?
so question is how can I do it?
推荐答案
的位置
酒店键入点
这是一个结构。
The Location
property has type Point
which is a struct.
而不是试图修改现有的点
,尝试分配一个新的点
对象:
Instead of trying to modify the existing Point
, try assigning a new Point
object:
this.balancePanel.Location = new Point(
this.optionsPanel.Location.X,
this.balancePanel.Location.Y
);
这篇关于C#更改对象的位置编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文