31 Aralık 2013 Salı

Picturebox klavye kontrol uygulama kodları

private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            int x = pictureBox1.Location.X;
            int y = pictureBox1.Location.Y;


            if (e.KeyCode == Keys.Right && x < 400)
                x += 5;
            else if (e.KeyCode == Keys.Left && x > 0)

                x -= 5;
            else if (e.KeyCode == Keys.Up && y > 0)
                y -= 5;
            else if (e.KeyCode == Keys.Down && y < 400)
                y += 5;

            pictureBox1.Location = new Point(x, y);

        }

Hiç yorum yok:

Yorum Gönder