Results 1 to 3 of 3

Thread: drag control using mouse

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6

    Unhappy drag control using mouse

    i am interested to move a panel control in a form by mouse dragging. how is this possible in vb.net?

    this is with moving a control on a form by mouse dragging and not the contents of a control.

    any help on this highly appreciated

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    518
    This should work for any control, does for panel and button:

    Code:
        Private Sub Panel1_MouseMove(ByVal sender As Object, _
        ByVal e As System.Windows.Forms.MouseEventArgs) _
        Handles Panel1.MouseMove
            If e.Button = MouseButtons.Left Then
                sender.Top = sender.Top + e.Y
                sender.Left = sender.Left + e.X
            End If
        End Sub
    although if you are working with a container that has children controls, I don't see how (or why) you would leave the children controls behind. Contents of the control are going along for the ride unless you want to take them out of the controlscollection of the control you want to move.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6
    Thanks! I will try this as soon as i reach home.

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