Jump to content
Sign in to follow this  
Sir Pereira

Controlos dinâmicos amovíveis

Recommended Posts

jnetic

Não conheço nenhuma propriedade que o permita.

Se quiseres implementar código, basta googlar e encontrarás milhares de snippets. Por exemplo:

Private Sub btnMove_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseDown
    If e.Button = MouseButtons.Left Then
        Dragging = True
        mousex = -e.X
        mousey = -e.Y
        Dim clipleft As Integer = Me.PointToClient(MousePosition).X - btnMove.Location.X
        Dim cliptop As Integer = Me.PointToClient(MousePosition).Y - btnMove.Location.Y
        Dim clipwidth As Integer = Me.ClientSize.Width - (btnMove.Width - clipleft)
        Dim clipheight As Integer = Me.ClientSize.Height - (btnMove.Height - cliptop)
        Cursor.Clip = Me.RectangleToScreen(New Rectangle(clipleft, cliptop, clipwidth, clipheight))
        btnMove.Invalidate()
    End If
End Sub

Private Sub btnMove_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseMove
    If Dragging Then
         'move control to new position
        Dim MPosition As New Point()
        MPosition = Me.PointToClient(MousePosition)
        MPosition.Offset(mousex, mousey)
        'ensure control cannot leave container
        btnMove.Location = MPosition
    End If
End Sub

Private Sub btnMove_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnMove.MouseUp
     If Dragging Then
        'end the dragging
        Dragging = False
        Cursor.Clip = Nothing
        btnMove.Invalidate()
    End If
End Sub 

Não testei, apenas copiei daqui: http://www.developerfusion.com/article/2692/drag-and-drop-in-windows-forms-a-primer/5/

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.