I am creating a simple program where a character (Picture Box) is moved using the arrow keys through adjusting the x and y. I have figured out how to detect key presses and adjust the x and y, but I cannot figure out how to redraw the picture box so that it moves. I have used Google but none of the answers are working. Any help is appreciated.

Recommended Answers

All 2 Replies

You have to set the location of the pic box...

Ex : Point mypoint=new Point(x,y);
picbox1.Location=mypoint;

Here x & y are integers that you adjust.

Call Me at [phone number removed].. If Any More Query...

I don't think you have to redraw the picture just set the starting position of picture box and update the start position by adding or subtracting every time one of the directional keys are pressed.

Do a search from a C# version of space invaders, I've done that in Java before and it includes moving an image with arrow keys.

Hope this helps at all.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.