How to Move an Image using Drag and Drop in Windows Form and C#

preview_player
Показать описание

Move an image with drag and drop is kind of important for many games and applications. We wanted to demonstrate a project where you can move an image in windows form with drag and drop. We want to do this using the dynamically drawn image on the screen. We will link a rectangle to the drawn image on the screen and use that to detect clicks and drags in the windows form. You can use any image of your choice for this tutorial. We are using the two images from the tutorial, you can download them from the link below.

Join the Flappy Bird Hunting Game in C# and OOP on Udemy -

LIKE - SUBSCRIBE
Help MOO grow to a better channel.
Рекомендации по теме
Комментарии
Автор

This is a great help. It is so much more rational than the Microsoft documentation on dragging and dropping in winforms!

LarghettoCantabile
Автор

Thanks for useful tutorial. I was developped restaurant management software. Now I can place the tables according to the design of the restaurant.

delidag
Автор

When you centre the pointer in the last step, you may want to comment out the update of rect.Location in FormMouseUp. All it really does is affect the coordinates in the text that displays, because the rectangle gets displayed at a different location (the one that is set in the timer event).

LarghettoCantabile
Автор

Thank you for the video. How can I use the original image I downloaded without setting height or width?

taiweezie
Автор

What theme are you using in Visual Studio?

andreiardelean
Автор

how to prevent the image going outside the form while dragging?

iamspy
Автор

if i wanted to add multiple images onto the same form, will i have to repeat this over and over?

Randmp
Автор

If you do not use a timer, you can get a smoother image. Still a nice video, good luck

EfeErsoy-js
Автор

My image keeps blinking, how can i fix it?

andrecardoso
Автор

Instead of copying the images into the bin folder you could also set the image property "Copy to output directory" to "Copy if newer", couldn't you?

JoeMeyer