Sinisterly
Silver [Code Sample]: Moveable Controls - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework)
+--- Thread: Silver [Code Sample]: Moveable Controls (/Thread-Silver-Code-Sample-Moveable-Controls)



[Code Sample]: Moveable Controls - miso - 04-21-2020

This code will allow the user to move any controls linked to this code

Preview:
[Image: move-obj.gif]

Sample:
Code:
Dim X, Y, point     Private Sub %ControlName%_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles %ControlName%.MouseMove         If e.Button = MouseButtons.Left Then             point = Control.MousePosition             point.X = Me.point.X - Me.X             point.Y = Me.point.Y - Me.Y             sender.Location = point         End If     End Sub     Private Sub %ControlName%_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles %ControlName%.MouseDown         X = Control.MousePosition.X - sender.Location.X         Y = Control.MousePosition.Y - sender.Location.Y     End Sub



RE: [Code Sample]: Moveable Controls - bumbuls6 - 11-26-2023

The only thing VB has going for it is the basic syntax if you grew on it so it has a sorta nostalgic value ("muh goto").