I wish the image in picture box could flip when key left is pressed, as the code shown below, but it didn't flip when key left is pressed. Anyone could help ? Thanks a lot!
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
KeyDown += new KeyEventHandler(Form1_KeyDown);
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
int x = pictureBox1.Location.X;
int y = pictureBox1.Location.Y;
if (e.KeyCode == Keys.Right)
{
x += 10;
}
else if (e.KeyCode == Keys.Left)
{
pictureBox1.Image.RotateFlip(RotateFlipType.Rotate180FlipX);
pictureBox1.Refresh();
x -= 10;
}
else if (e.KeyCode == Keys.Up)
{
y -= 10;
}
pictureBox1.Location = new Point (x, y);
pictureBox1.Invalidate();
}
}
}