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

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 พ.ย. 2024

ความคิดเห็น • 16

  • @delidag
    @delidag หลายเดือนก่อน

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

  • @LarghettoCantabile
    @LarghettoCantabile ปีที่แล้ว +2

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

    • @mooict
      @mooict  ปีที่แล้ว

      Glad it was helpful!

  • @LarghettoCantabile
    @LarghettoCantabile ปีที่แล้ว

    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).

  • @EfeErsoy-j3s
    @EfeErsoy-j3s 3 หลายเดือนก่อน

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

  • @taiweezie
    @taiweezie 8 หลายเดือนก่อน

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

  • @ozkanozdemir6255
    @ozkanozdemir6255 ปีที่แล้ว +1

    Thank you...🙏

  • @andreiardelean9440
    @andreiardelean9440 ปีที่แล้ว

    What theme are you using in Visual Studio?

  • @JoeMeyer8998
    @JoeMeyer8998 ปีที่แล้ว +1

    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?

    • @mooict
      @mooict  ปีที่แล้ว

      Yes you could also do that.

  • @iamspy8847
    @iamspy8847 7 หลายเดือนก่อน +1

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

    • @mooict
      @mooict  7 หลายเดือนก่อน

      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);
      }*

  • @Rand0mp
    @Rand0mp ปีที่แล้ว

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

    • @mooict
      @mooict  ปีที่แล้ว

      I’ve done one for moving multiple images on the channel you’ll find it on the videos list 👍🏽

  • @andrecardoso8440
    @andrecardoso8440 ปีที่แล้ว

    My image keeps blinking, how can i fix it?

    • @mooict
      @mooict  ปีที่แล้ว

      Enable double buffer on the form