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).
Thanks for useful tutorial. I was developped restaurant management software. Now I can place the tables according to the design of the restaurant.
This is a great help. It is so much more rational than the Microsoft documentation on dragging and dropping in winforms!
Glad it was helpful!
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).
If you do not use a timer, you can get a smoother image. Still a nice video, good luck
Thank you for the video. How can I use the original image I downloaded without setting height or width?
Thank you...🙏
What theme are you using in Visual Studio?
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?
Yes you could also do that.
how to prevent the image going outside the form while dragging?
You can change the mouse move event to this -
*if (dragging)
{
if (position.X < 0)
{
dragging = false;
position.X = 3;
}
else if (position.X + width > this.ClientSize.Width)
{
position.X = this.ClientSize.Width - (width + 3);
dragging = false;
}
else if (position.Y < 0)
{
dragging=false;
position.Y = 3;
}
else if (position.Y + height > this.ClientSize.Height)
{
position.Y = this.ClientSize.Height - (height + 3);
dragging = false;
}
else
{
position.X = e.X - (width / 2);
position.Y = e.Y - (height / 2);
}*
if i wanted to add multiple images onto the same form, will i have to repeat this over and over?
I’ve done one for moving multiple images on the channel you’ll find it on the videos list 👍🏽
My image keeps blinking, how can i fix it?
Enable double buffer on the form