dragdrop

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Hello,

drag and drop works fine, but it differs from VB6. In VB6 when I drag a
control the control follows the mouse.
Am I correct in the assumption that in VB.NET I myself have to change the
controls top/left attributes (in the mousemove event) to let it follow the
mouse?
Thanks
Frank
 
Hi this is a piece of code to move a control at design time by dragging and
dropping.

<<<<<<<code>>>>>>>>
Private dragging As Boolean
Private beginX, beginY As Integer

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

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

End Sub

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

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

dragging = False

End Sub

<<<<<<<<code>>>>>>>>

hth Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top