Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to move picturebox along with cursor movements

How to move picturebox along with cursor movements

Scheduled Pinned Locked Moved C#
helpcomdesigntutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chintan Desai
    wrote on last edited by
    #1

    Hi all guys, I am building one eFlowchart whose work is similar to normal paper flowchart.There are lots of picturebox ctrl on eFlowchart.I hav to allow author to connect all picturebox with its connector. But main problem is how to move picturebox smoothly with mouse cursor.I am using mouse_down and mouse_move event. I have taken click coordinates in mouse_down event with e.x and e.y and then making plus-minus in mouse_move event, but still I am getting slight a bit roughness in ctrl movements.ctrl in design time in visual studios are very smooth,I wanna that type of smoothness. Pls help Thank you guys.

    Regards Chintan www.visharadsoft.com (I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)

    A 1 Reply Last reply
    0
    • C Chintan Desai

      Hi all guys, I am building one eFlowchart whose work is similar to normal paper flowchart.There are lots of picturebox ctrl on eFlowchart.I hav to allow author to connect all picturebox with its connector. But main problem is how to move picturebox smoothly with mouse cursor.I am using mouse_down and mouse_move event. I have taken click coordinates in mouse_down event with e.x and e.y and then making plus-minus in mouse_move event, but still I am getting slight a bit roughness in ctrl movements.ctrl in design time in visual studios are very smooth,I wanna that type of smoothness. Pls help Thank you guys.

      Regards Chintan www.visharadsoft.com (I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Hi Chintan, Here is ur soln~:laugh::laugh: Delcare these varibale as private Private dragging As Boolean Private beginX, beginY As Integer Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown dragging = True beginX = e.X beginY = e.Y End Sub Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp dragging = False End Sub Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If dragging = True Then PictureBox1.Location = New Point(PictureBox1.Location.X + e.X - beginX, PictureBox1.Location.Y + e.Y - beginY) Me.Refresh() End If End Sub Good luck :cool::cool: Let me know when done !!!! ;)

      Happy Programming ----- Abhijit

      C 1 Reply Last reply
      0
      • A Abhijit Jana

        Hi Chintan, Here is ur soln~:laugh::laugh: Delcare these varibale as private Private dragging As Boolean Private beginX, beginY As Integer Private Sub PictureBox1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown dragging = True beginX = e.X beginY = e.Y End Sub Private Sub PictureBox1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp dragging = False End Sub Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If dragging = True Then PictureBox1.Location = New Point(PictureBox1.Location.X + e.X - beginX, PictureBox1.Location.Y + e.Y - beginY) Me.Refresh() End If End Sub Good luck :cool::cool: Let me know when done !!!! ;)

        Happy Programming ----- Abhijit

        C Offline
        C Offline
        Chintan Desai
        wrote on last edited by
        #3

        Hi abhijit Ya, you are correct tht I had already posted the question and also got the solution frm u,but all this I had programmed for child picture boxes on form control, but now as my requirement got change, I have to move every child picturebox on picture box ctrl ( instead of form control ). When i move the child picturebox on picture control from xy1 location to xy2 location then picture looks like blur ( it seems that its own ghost is following at each mouse_move event).I am not getting the smotheness in dragging. pls reply thx

        Regards Chintan www.visharadsoft.com (I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups