using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace c5_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int x, y; private void Form1_KeyDown(object sender, KeyEventArgs e) { switch(e.KeyCode) { case Keys.Right: x += 5; break; case Keys.Left: x -= 5; break; case Keys.Down: y += 5; break; case Keys.Up: y -= 5; break; } pictureBox1.Location = new Point(x, y); label1.Text = x.ToString() + "," + y.ToString(); } private void Form1_Load(object sender, EventArgs e) { x = pictureBox1.Location.X; y = pictureBox1.Location.Y; // this.KeyPreview = true; } } }