Move Form With Mouse Drag
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
1 post
Page 1 of 1
Hey All,
I have re made the tutorial Move Form With Mouse Drag, so that it works in Visual Studio 2015.
https://www.youtube.com/watch?v=Q8N9LYqNzIc
If you want any help feel free to ask.
Please +rep if you liked the tutorial.
I have re made the tutorial Move Form With Mouse Drag, so that it works in Visual Studio 2015.
https://www.youtube.com/watch?v=Q8N9LYqNzIc
Code: Select all
This can easily be modified to use on controls within the form, so you can move around controls at run time by moving the mouse. Public Class frmMain
Public BeingDragged As Boolean = False
Public MouseDownX As Integer
Public MouseDownY As Integer
Private Sub frmMain_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
If e.Button = MouseButtons.Left Then
BeingDragged = True
MouseDownX = e.X
MouseDownY = e.Y
End If
End Sub
Private Sub frmMain_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If BeingDragged = True Then
Dim tmp As Point = New Point()
tmp.X = Me.Location.X + (e.X - MouseDownX)
tmp.Y = Me.Location.Y + (e.Y - MouseDownY)
Me.Location = tmp
tmp = Nothing
End If
End Sub
Private Sub frmMain_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
If e.Button = MouseButtons.Left Then
BeingDragged = False
End If
End Sub
End Class
If you want any help feel free to ask.
Please +rep if you liked the tutorial.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023