Home All Groups Group Topic Archive Search About
Author
22 Jun 2006 2:50 PM
Tull Clancey
Does anyone have, or can anyone suggest a URL for code to drag a control
around a form at run time?  VB.Net 2003.

I have written stuff in VB6 to do this before, but a long time ago and I
don't have the code to refer to anymore.

Cheers,
Tull.

Author
22 Jun 2006 3:01 PM
Peter Proost
This is sample code for dragging a button at runtime, should be easy to
modify for other controls

Hope this helps
<<<<<<code>>>>>>


Private dragging As Boolean
Private beginX, beginY As Integer


Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown


    dragging = True
    beginX = e.X
    beginY = e.Y


End Sub


Private Sub Button2_MouseMove(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseMove
    If dragging = True Then
        Button2.Location = New Point(Button2.Location.X + e.X -
beginX,Button2.Location.Y + e.Y - beginY)
        Me.Refresh()
    End If
End Sub


Private Sub Button2_MouseUp(ByVal sender As Object, ByVal e As _
System.Windows.Forms.MouseEventArgs) Handles Button2.MouseUp


    dragging = False


End Sub






--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)

Show quoteHide quote
"Tull Clancey" <tull.clan***@btopenworld.com> schreef in bericht
news:KMGdnT3P88loMQfZRVnygw@bt.com...
> Does anyone have, or can anyone suggest a URL for code to drag a control
> around a form at run time?  VB.Net 2003.
>
> I have written stuff in VB6 to do this before, but a long time ago and I
> don't have the code to refer to anymore.
>
> Cheers,
> Tull.
>
>
Author
22 Jun 2006 6:19 PM
Cor Ligthert [MVP]
Hi Tull,

http://www.vb-tips.com/default.aspx?ID=c1be07ed-e66b-4080-bc11-47ef665ea0c2

I hope this helps,

Cor

Show quoteHide quote
"Tull Clancey" <tull.clan***@btopenworld.com> schreef in bericht
news:KMGdnT3P88loMQfZRVnygw@bt.com...
> Does anyone have, or can anyone suggest a URL for code to drag a control
> around a form at run time?  VB.Net 2003.
>
> I have written stuff in VB6 to do this before, but a long time ago and I
> don't have the code to refer to anymore.
>
> Cheers,
> Tull.
>