Movable controls but read ...
Posted: Sat Mar 27, 2010 12:36 am
How do i make movable controls like
dim btn as new button
make the btn movable?
dim btn as new button
make the btn movable?
Sharing, Teaching and Supporting coders of all ages and levels since 2009
https://www.codenstuff.com/forum/
Dim a
Dim b
Dim capt = 0
Dim btn As New Button
btn.Size = New Size(100, 100) 'CHANGE TO THE HEIGHT AND WIDTH OF YOUR BUTTON
btn.Location = New Point(100, 100) 'CHANGE TO THE LOCATION FOR IT TO BE CREATED
AddHandler btn.MouseDown, AddressOf btn_Down
AddHandler btn.MouseUp, AddressOf btn_Up
AddHandler btn.MouseMove, AddressOf btn_Move
Me.Controls.Add(btn)
Private Sub btn_Down(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
a = e.X
b = e.Y
capt = 1
End Sub
Private Sub btn_Up(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
CType(sender, Button).Location = New Point(CType(sender, Button).Location.X + (e.X - a), CType(sender, Button).Location.Y + (e.Y - b))
capt = 0
End Sub
Private Sub btn_Move(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If capt = 1 Then
CType(sender, Button).Location = New Point(CType(sender, Button).Location.X + (e.X - a), CType(sender, Button).Location.Y + (e.Y - b))
End If
End Sub