Copyright Codenstuff.com 2016
YOU NEED TO BE LOGGED IN TO USE THIS FEATURE


Register
Credits
0
Reputation
0

----

----
NEWS
New Visual Studio Toys
At this years Microsoft Connect(); event they announced a whole bunch of new development software, including Visual Studio 2017
Read more..
NEWS
Echo. Echo. Echo.
The Amazon Echo has been around for a while in the US and is now available in the UK. But what is it and why do you need it.
Read more..
NEWS
Nintendo Switch
Nintendo does it again. Meet the long rumored and eagerly anticipated new Nintendo games console, the Switch.
Read more..
SHOUT
A few site fixes
We're always working hard to make the site better and function correctly. Today we have made a few repairs that should make the user experience better.
Read more..
NEWS
Windows 10 woes
Consumer watchdog, Which?, has challenged Microsoft over Windows 10 upgrade problems and urges them to pay compensation.
Read more..

----

----

----
User avatar Move Form With Mouse Drag
smashapps Sat Dec 12, 2015 4:47 am
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

Code: Select all
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


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.

If you want any help feel free to ask.

Please +rep if you liked the tutorial.

----