我试图使它当我按下向上箭头时,它将图片框向上移动,向下箭头向下移动等。但我似乎无法让它工作。这是给我的错误:我似乎无法移动C#中的图片框的位置
Can't modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable
这是我的代码:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Up)
{
ImgGuy.Location.Y--;
}
else if (e.KeyCode == Keys.Down)
{
ImgGuy.Location.Y++;
}
else if (e.KeyCode == Keys.Left)
{
ImgGuy.Location.X--;
}
else if (e.KeyCode == Keys.Right)
{
ImgGuy.Location.X++;
}
任何帮助是极大的赞赏。
谢谢你,没有解决我有错误,但是,它给了我两个新: “不能隐式地将'int'转换为'System.Drawing.Point'” 和 “只能使用assingnent,call,increment,decrement和新的对象表达式作为语句。 – Bondca
@Bondca使用的危险'l'作为一个变量名,它看起来很像'1'(我猜是g这就是发生了什么 - 你用一个而不是一个ell) –
噢抱歉!和好的发现,谢谢@MatthewWatson – gzaxx