Results 1 to 2 of 2

Thread: Drag a Panel around.......

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Posts
    142

    Drag a Panel around.......

    I have a panel on aform.
    Does any1 know how to make it so the user can move the panel around the form with the mouse???

    Thanks,
    Bebandit

  2. #2
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    This will do it...

    Private myX As Int32
    Private myY As Int32
    Private Moving As Boolean

    Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
    myX = e.X
    myY = e.Y
    Moving = True
    End Sub

    Private Sub Panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseUp
    Moving = False
    End Sub

    Private Sub Panel1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseMove
    If Moving = True Then
    Dim myPoint As New Point
    myPoint.X = Panel1.Location.X + (e.X - myX)
    myPoint.Y = Panel1.Location.Y + (e.Y - myY)
    Panel1.Location = myPoint
    End If
    End Sub
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width